Shard by-id mount entries
This commit is contained in:
@@ -123,12 +123,25 @@ func buildMountTree(ctx context.Context, client *DocspellClient, items []SearchI
|
||||
byIDName = fmt.Sprintf("%s-%d%s", item.ID, i+1, ext)
|
||||
}
|
||||
}
|
||||
byID.children[uniqueName(byID.children, sanitizeName(byIDName))] = node
|
||||
shard := idShard(item.ID)
|
||||
shardDir := ensureDir(byID, shard)
|
||||
shardDir.children[uniqueName(shardDir.children, sanitizeName(byIDName))] = node
|
||||
}
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
||||
func idShard(id string) string {
|
||||
id = sanitizeName(id)
|
||||
if len(id) >= 2 {
|
||||
return id[:2]
|
||||
}
|
||||
if id != "" {
|
||||
return id
|
||||
}
|
||||
return "__"
|
||||
}
|
||||
|
||||
func ensureDir(root *dirNode, first string, rest ...string) *dirNode {
|
||||
cur := root
|
||||
parts := append([]string{first}, rest...)
|
||||
|
||||
Reference in New Issue
Block a user