diff --git a/ui/dr-ui/src/library/thumbnails_fetch.rs b/ui/dr-ui/src/library/thumbnails_fetch.rs index 92c3603..1b9479f 100644 --- a/ui/dr-ui/src/library/thumbnails_fetch.rs +++ b/ui/dr-ui/src/library/thumbnails_fetch.rs @@ -890,6 +890,9 @@ pub(super) fn serve_prefetches(shared: &PrefetchShared, events: &Sender bool { +/// +/// Asked on `held`, which the caller keeps across a batch of these: a +/// connection per question was an open per prefetched neighbour, four of the +/// five a develop landing made. Opened here on first use, and again only if +/// the batch moves to another catalog. +pub(super) fn holds_original(cache: &CacheContext, held: &mut Option<(PathBuf, Catalog)>) -> bool { let Ok(store) = dr_catalog::Cache::open(&cache.dir, cache.budget) else { return false; }; - let Ok(catalog) = Catalog::open(&cache.catalog_path) else { + if held + .as_ref() + .is_none_or(|(path, _)| *path != cache.catalog_path) + { + *held = Catalog::open(&cache.catalog_path) + .ok() + .map(|c| (cache.catalog_path.clone(), c)); + } + let Some((_, catalog)) = held.as_ref() else { return false; }; store.holds_original(catalog.connection(), cache.image)