From 5be035a172a7d6e1088d530db8c02d1b276b5a96 Mon Sep 17 00:00:00 2001 From: Diocrafts Date: Sun, 12 Apr 2026 00:56:58 +0200 Subject: [PATCH] fix: restore ext-thumbnail disk lookup in get_cached_thumbnail After the blob_hash dedup change, get_cached_thumbnail with blob_hash=None (cache-first fast path) only checked moka. External video thumbnails stored as ext-{file_id}.jpg on disk were not found after a server restart when moka is empty. Now checks ext-{file_id}.jpg on disk before falling through to the blob-hash disk lookup, so video thumbnails survive restarts. --- src/infrastructure/services/thumbnail_service.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/services/thumbnail_service.rs b/src/infrastructure/services/thumbnail_service.rs index eca84729..bd65e442 100644 --- a/src/infrastructure/services/thumbnail_service.rs +++ b/src/infrastructure/services/thumbnail_service.rs @@ -280,7 +280,19 @@ impl ThumbnailService { return Some(bytes); } - // 2. Check disk (needs blob_hash to locate the shared file) + // 2. Check disk for external (video-frame) thumbnails stored by file_id. + // These don't require blob_hash since they use ext-{file_id}.jpg paths. + let ext_path = self + .thumbnails_root + .join(size.dir_name()) + .join(format!("ext-{}.jpg", file_id)); + if let Ok(data) = fs::read(&ext_path).await { + let bytes = Bytes::from(data); + self.cache.insert(cache_key.clone(), bytes.clone()).await; + return Some(bytes); + } + + // 3. Check disk for blob-hash thumbnails (needs blob_hash to locate) let hash = blob_hash?; let thumb_path = self.get_thumbnail_path(hash, size); if let Ok(data) = fs::read(&thumb_path).await {