fix(artwork): give full-size disc art a real ETag

Regression from 04d5a556. Keying the resize cache on identity meant the
disc response no longer carried a content hash, and the full-size branch
set no ETag either — so WriteImageHeaders fell back to the empty hash
and emitted `ETag: ""` for every full-size disc image. Since ifNoneMatch
compares the unquoted value, a client echoing that back matched, and got
a 304 even after the image was replaced.

The full-size branch now carries the same identity validator the sized
branch uses, so it moves when the folder's images change.

WriteImageHeaders is hardened against the class as well: an empty
validator is no validator, so it is neither emitted nor matched.

Reported by Codex on #5847.
This commit is contained in:
Deluan 2026-07-25 15:06:51 -04:00
commit 6bb3e98e4c
4 changed files with 48 additions and 10 deletions

View file

@ -28,7 +28,11 @@ func WriteImageHeaders(w http.ResponseWriter, r *http.Request, img *artwork.Imag
if etag == "" {
etag = img.Hash
}
h.Set("ETag", `"`+etag+`"`)
// An empty validator is not one: emitting it would hand every such response the same ETag,
// and matching it would 304 a client that echoed it back even after the bytes changed.
if etag != "" {
h.Set("ETag", `"`+etag+`"`)
}
if !img.LastUpdated.IsZero() {
h.Set("Last-Modified", img.LastUpdated.UTC().Format(http.TimeFormat))
}
@ -40,7 +44,7 @@ func WriteImageHeaders(w http.ResponseWriter, r *http.Request, img *artwork.Imag
h.Set("Cache-Control", "public, no-cache")
}
if ifNoneMatch(r.Header.Get("If-None-Match"), etag) {
if etag != "" && ifNoneMatch(r.Header.Get("If-None-Match"), etag) {
w.WriteHeader(http.StatusNotModified)
return true
}