fix(artwork): only force blurhash recompute on original-size cache misses

Resized cache keys vary per requested size, so a first request for a new
thumbnail size (or an evicted resized entry) forced a recompute with an
unchanged source — wasted work, and a transient failure during it could
clear a valid stored hash. Resized readers re-fetch the original through
Get, so the original-size call still carries the real change signal.
This commit is contained in:
Deluan 2026-07-17 13:16:07 -04:00
parent 9ac2c6a5e3
commit 0e74cf0ab1

View File

@ -83,9 +83,11 @@ func (a *artwork) Get(ctx context.Context, artID model.ArtworkID, size int, squa
return nil, time.Time{}, err
}
if a.blurHashes != nil {
// A miss on an operational cache means a new/changed image even when no entity row moved;
// while warming up or disabled every serve misses, so only the LastUpdated signal applies.
force := !r.Cached && a.cache.Available(ctx)
// An original-size miss on an operational cache means a new/changed image even when no
// entity row moved. Resized misses don't qualify (their keys vary per size, and their
// readers re-fetch the original through Get, carrying the real signal); nor does cache
// warmup/disabled, where every serve misses — there the LastUpdated signal applies.
force := size == 0 && !square && !r.Cached && a.cache.Available(ctx)
a.blurHashes.Enqueue(artID, artReader.LastUpdated(), force)
}
return r, artReader.LastUpdated(), nil