Artwork reader for Artist

This commit is contained in:
Deluan
2022-12-31 16:58:07 -05:00
committed by Deluan Quintão
parent bf461473ef
commit 918fee3ea3
11 changed files with 99 additions and 24 deletions
+8 -2
View File
@@ -53,10 +53,13 @@ func (api *Router) getPlaceHolderAvatar(w http.ResponseWriter, r *http.Request)
}
func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
defer cancel()
id := utils.ParamString(r, "id")
size := utils.ParamInt(r, "size", 0)
imgReader, lastUpdate, err := api.artwork.Get(r.Context(), id, size)
imgReader, lastUpdate, err := api.artwork.Get(ctx, id, size)
w.Header().Set("cache-control", "public, max-age=315360000")
w.Header().Set("last-modified", lastUpdate.Format(time.RFC1123))
@@ -72,7 +75,10 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons
}
defer imgReader.Close()
_, err = io.Copy(w, imgReader)
cnt, err := io.Copy(w, imgReader)
if err != nil {
log.Warn(ctx, "Error sending image", "count", cnt, err)
}
return nil, err
}