feat(phase 4): vision fetches NC previews; stop writing /data/thumbs
Last consumer of the on-disk thumbnail pipeline was the vision
worker reading /data/thumbs/{id}/medium.webp. Now it asks Nextcloud
for a 640px preview (the same edge size the old thumb used) and
decodes the bytes in-memory — no disk dependency.
- nextcloud_dav.get_preview_bytes: sync sibling of get_preview_async,
for the celery vision worker (which is sync).
- vision._load_thumb: tries NC preview first; transitional disk
fallback stays for rows still indexed during the rollout.
- thumbs.WORKER_THUMB_SIZES = set() — generate_thumbnails still runs
the decode + pHash side-effect (perceptual dedup is mule-only and
needs original-resolution pixels) but no longer writes thumbnail
files.
The HTTP thumbnail endpoint's disk fallback path stays in place
unchanged: for NC-404 cases (e.g. iPhone JPEGs mis-extensioned as
.DNG), inline Pillow regeneration still writes a tiny per-photo
file so subsequent requests are fast. That path is rare and the
files are small.
Disk impact: /data/thumbs currently has ~22k medium.webp totaling
~1 GB. They'll stop being read after the worker-vision container
restarts, but no automatic delete — purge with the same find
pattern used for small/large reclaim when ready:
find /data/thumbs -name "medium.webp" -delete
This commit is contained in:
@@ -47,13 +47,13 @@ THUMB_SIZES = {
|
||||
'large': settings.thumbnails.large
|
||||
}
|
||||
|
||||
# Sizes the worker actually writes to /data/thumbs. We used to write all
|
||||
# three, but the API now proxies Nextcloud's /core/preview for `small`
|
||||
# and `large` — only `medium` survives on disk because the vision
|
||||
# pipeline (app.tasks.vision) still loads it from there. When vision
|
||||
# moves to NC previews too, this set drops to empty and the file
|
||||
# pipeline can be deleted entirely.
|
||||
WORKER_THUMB_SIZES = {'medium'}
|
||||
# Sizes the worker writes to /data/thumbs. Empty set since Phase 4 —
|
||||
# the API serves all sizes via Nextcloud's /core/preview proxy, and
|
||||
# the vision worker also fetches NC previews on demand instead of
|
||||
# reading a local cache. generate_thumbnails still runs the decode-
|
||||
# and-pHash side-effect (perceptual dedup is mule-only and needs the
|
||||
# original-resolution pixels) but no longer touches the disk.
|
||||
WORKER_THUMB_SIZES: set[str] = set()
|
||||
|
||||
def get_thumb_path(photo_id: str, size: str, user_id: str = None) -> str:
|
||||
"""Get the path for a thumbnail file.
|
||||
|
||||
Reference in New Issue
Block a user