mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-05 21:47:36 +03:00
fix(subsonic): check errors before setting headers for getCoverArt
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
5fa19f9cfa
commit
d6ec52b9d4
1 changed files with 3 additions and 3 deletions
|
@ -67,9 +67,6 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons
|
||||||
square := p.BoolOr("square", false)
|
square := p.BoolOr("square", false)
|
||||||
|
|
||||||
imgReader, lastUpdate, err := api.artwork.GetOrPlaceholder(ctx, id, size, square)
|
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 {
|
switch {
|
||||||
case errors.Is(err, context.Canceled):
|
case errors.Is(err, context.Canceled):
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -82,6 +79,9 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons
|
||||||
}
|
}
|
||||||
|
|
||||||
defer imgReader.Close()
|
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)
|
cnt, err := io.Copy(w, imgReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn(ctx, "Error sending image", "count", cnt, err)
|
log.Warn(ctx, "Error sending image", "count", cnt, err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue