Add by-id mount directory

This commit is contained in:
Jan Bader
2026-07-13 23:12:32 +02:00
parent 621fbe4913
commit 385ad6adad
2 changed files with 35 additions and 1 deletions
+12 -1
View File
@@ -73,6 +73,8 @@ func runMountCommand(args []string, cfg config, password string) error {
func buildMountTree(ctx context.Context, client *DocspellClient, items []SearchItem) *dirNode {
root := &dirNode{name: "", children: map[string]fs.Node{}}
byID := &dirNode{name: "by-id", children: map[string]fs.Node{}}
root.children["by-id"] = byID
for _, item := range items {
if full, err := client.GetItem(ctx, item.ID); err == nil {
item = *full
@@ -112,7 +114,16 @@ func buildMountTree(ctx context.Context, client *DocspellClient, items []SearchI
}
}
name = uniqueName(dir.children, sanitizeName(name))
dir.children[name] = &fileNode{name: name, attachmentID: att.ID, size: uint64(size), knownSize: size > 0, modTime: modTime, client: client}
node := &fileNode{name: name, attachmentID: att.ID, size: uint64(size), knownSize: size > 0, modTime: modTime, client: client}
dir.children[name] = node
byIDName := item.ID + ext
if len(item.Attachments) > 1 {
if i > 0 {
byIDName = fmt.Sprintf("%s-%d%s", item.ID, i+1, ext)
}
}
byID.children[uniqueName(byID.children, sanitizeName(byIDName))] = node
}
}
return root