fix: return friendly paths for lazily mounted items

Fetch the uniquely identified item when mount metadata has not yet been
populated, so get-path does not fall back to the ID-based location.

💘 Generated with Crush

Assisted-by: Crush:openai/gpt-5.6-terra
This commit is contained in:
Jan Bader committed 2026-10-07 10:41:11 +02:00
1 parent 6041cc0a33
commit d15b7d082e
2 files changed
+41

No files matched your search

+19
View File
@@ -338,3 +338,22 @@ func TestFriendlyLocalPathForItemIDUsesMetadata(t *testing.T) {
t.Fatalf("expected %q, got %q", want, got)
}
}
func TestFriendlyLocalPathForSearchItemsUsesFriendlyPath(t *testing.T) {
mountPath := t.TempDir()
items := []SearchItem{{
ID: "EkXte7yy5Yw-Tb1coaAtAQY-7WL61AMHGLQ-56kX2TaRabG",
Name: "Invoice",
Date: 1720396800000,
Folder: &DocspellEntity{
Name: "Bills",
},
Attachments: []ItemAttachment{{ID: "att-1", Name: "invoice.pdf"}},
}}
got := friendlyLocalPathForSearchItems(mountPath, itemIDFromURLOrID("https://docs.javil.eu/app/item/EkXte7yy5Yw-Tb1coaAtAQY-7WL61AMHGLQ-56kX2TaRabG"), items)
want := filepath.Join(mountPath, "Bills", "2024", "07", "Invoice.pdf")
if got != want {
t.Fatalf("expected %q, got %q", want, got)
}
}