feat: thumbnail dedup — store thumbnails by blob_hash instead of file_id (#233)

Thumbnails are now keyed by blob_hash on disk so identical files share
a single set of thumbnails (icon/preview/large). For 4000 duplicate
files with the same content, this reduces thumbnail storage from 12,000
files to just 3.

Changes:
- get_thumbnail_path() keys by blob_hash instead of file_id
- get_thumbnail(), get_cached_thumbnail(), generate_all_sizes_background()
  accept blob_hash parameter for disk dedup
- generate_all_sizes_background() fast path: if blob-hash thumbnails
  already exist on disk, skip image processing entirely and just
  populate moka cache for the new file_id
- delete_thumbnails() only invalidates moka cache (shared disk
  thumbnails must not be deleted when one file is removed)
- delete_blob_thumbnails() added for GC; garbage_collect() now cleans
  up orphaned thumbnail files alongside blob files
- External thumbnails (video frames) stored as ext-{file_id}.jpg
  since they are client-generated and not dedup-able
- ThumbnailPort trait updated with blob_hash parameters
- All handler call sites updated (file_handler, preview_handler)
- Tests updated for new signatures
This commit is contained in:
Diocrafts
2026-04-12 00:50:10 +02:00
parent e91dcee0ea
commit 2dde4da5cf
6 changed files with 164 additions and 41 deletions
+1 -1
View File
@@ -146,7 +146,7 @@ pub async fn handle_preview(
match state
.core
.thumbnail_service
.get_thumbnail(&object_id, thumb_size.into(), &blob_path)
.get_thumbnail(&object_id, &blob_hash, thumb_size.into(), &blob_path)
.await
{
Ok(data) => {