mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-24 10:09:01 -06:00
Reopening a library (or opening another one, or set_disk_cache_bytes falling back to attaching) replaced MediaCache::rendered with a new PreviewCache, but render jobs still in flight kept the old object. Each PreviewCache checked only its own generation, so after a clear on the new cache the old one's generation was still current: a finishing thumbnail job wrote its pixels through it into the directory the clear had just emptied. The UI rejected the result, but the JPEG stayed. attach_disk_cache now retires the cache it replaces before swapping it: PreviewCache::retire takes the generation write lock (so it waits for a write in progress, like clear) and marks the object retired; every get/put/put_deferred through it is then refused and its clear() is a no-op, as its directory may now belong to the replacement. Files on disk are left alone, so a plain reopen still finds its thumbnails, and resizing the budget in place keeps the same cache object as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>