Skip to main content

Module thumb_cache

Module thumb_cache 

Source

Functions§

cache_dir
Directory holding pre-converted HEIC thumbnails, keyed by content hash rather than file path, the same photo scanned into different databases only needs converting once. Mirrors this project’s existing ~/.cache/ort/ convention for cached model weights.
face_thumb_exists
True if a cached face crop already exists for this hash/face_id/size.
face_thumb_path
Cache path for a single face crop. Distinct from thumb_path because many faces can share one source hash, the face id disambiguates.
hash_from_cache_filename
Extracts the leading content hash from a cache filename (the .jpg files this module writes, thumb_path, face_thumb_path, original_path), or None if filename doesn’t match that shape. Used by videre prune to find cache entries whose hash no longer has a surviving file_hashes row, without hardcoding every suffix pattern this module can produce. Deliberately does NOT match .tmp* scratch files (see thumb_tmp_path/original_tmp_path), those may be actively being written by a concurrently running videre watch, and reusing this same hash-existence check against them could delete an in-flight write for a hash that is still perfectly valid.
migrate_legacy_dupe_cache
One-time migration from the pre-rename cache location. Thumbnails are content-hash keyed and expensive to regenerate for large HEIC libraries, so a rename of the tool should not orphan them. Only fires when the old dir exists and the new one does not; a plain rename, so it is atomic on the same filesystem and a no-op on any error (cache regenerates lazily).
original_exists
True if a cached full-resolution original already exists for this hash.
original_path
Cache path for a full-resolution HEIC-converted original. One per hash (not per face, the original photo is the same regardless of which face on it was clicked).
original_tmp_path
Scratch path for writing a full-res original before it’s atomically renamed into place at original_path, mirrors thumb_tmp_path’s same-filesystem-atomic-rename pattern and process-id disambiguation.
thumb_exists
True if a cached thumbnail already exists for this hash/size.
thumb_path
Path to a cached thumbnail for hash at size pixels (e.g. 240 or 1200), whether or not it currently exists on disk.
thumb_tmp_path
Path to a scratch file for writing a thumbnail before it’s atomically renamed into place at thumb_path. Lives in the same directory as the final file so the rename is same-filesystem (and thus atomic on POSIX). Includes the current process ID so concurrent writers (e.g. two videre watch instances, or a leftover file from a crashed process) don’t collide on the same temp name.