From d6ec52b9d41f1812e7c525e4644c413104b566a0 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 25 Feb 2025 08:22:38 -0500 Subject: [PATCH] fix(subsonic): check errors before setting headers for getCoverArt Signed-off-by: Deluan --- server/subsonic/media_retrieval.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/subsonic/media_retrieval.go b/server/subsonic/media_retrieval.go index 12d0129bc..b960c71db 100644 --- a/server/subsonic/media_retrieval.go +++ b/server/subsonic/media_retrieval.go @@ -67,9 +67,6 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons square := p.BoolOr("square", false) imgReader, lastUpdate, err := api.artwork.GetOrPlaceholder(ctx, id, size, square) - w.Header().Set("cache-control", "public, max-age=315360000") - w.Header().Set("last-modified", lastUpdate.Format(time.RFC1123)) - switch { case errors.Is(err, context.Canceled): return nil, nil @@ -82,6 +79,9 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons } defer imgReader.Close() + w.Header().Set("cache-control", "public, max-age=315360000") + w.Header().Set("last-modified", lastUpdate.Format(time.RFC1123)) + cnt, err := io.Copy(w, imgReader) if err != nil { log.Warn(ctx, "Error sending image", "count", cnt, err)