🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Handle empty cover art ID in subsonic API
Deluanabd3274250e8
diff --git a/core/artwork.go b/core/artwork.goindex c07e62c48..5b2ddf609 100644--- a/core/artwork.go+++ b/core/artwork.go@@ -41,9 +41,13 @@ type artwork struct {}func (a *artwork) Get(ctx context.Context, id string, size int) (io.ReadCloser, error) {- artID, err := model.ParseArtworkID(id)- if err != nil {- return nil, errors.New("invalid ID")+ var artID model.ArtworkID+ var err error+ if id != "" {+ artID, err = model.ParseArtworkID(id)+ if err != nil {+ return nil, errors.New("invalid ID")+ }}key := &artworkKey{a: a, artID: artID, size: size}diff --git a/core/artwork_internal_test.go b/core/artwork_internal_test.goindex 6139fd3fa..d0b2980ee 100644--- a/core/artwork_internal_test.go+++ b/core/artwork_internal_test.go@@ -41,6 +41,14 @@ var _ = Describe("Artwork", func() {aw = NewArtwork(ds, cache).(*artwork)})+ Context("Empty ID", func() {+ It("returns placeholder if album is not in the DB", func() {+ _, path, err := aw.get(context.Background(), model.ArtworkID{}, 0)+ Expect(err).ToNot(HaveOccurred())+ Expect(path).To(Equal(consts.PlaceholderAlbumArt))+ })+ })+Context("Albums", func() {Context("ID not found", func() {It("returns placeholder if album is not in the DB", func() {diff --git a/server/subsonic/media_retrieval.go b/server/subsonic/media_retrieval.goindex 78221c870..414edf8f3 100644--- a/server/subsonic/media_retrieval.go+++ b/server/subsonic/media_retrieval.go@@ -51,7 +51,7 @@ func (api *Router) getPlaceHolderAvatar(w http.ResponseWriter, r *http.Request)}func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {- id := utils.ParamStringDefault(r, "id", "non-existent")+ id := utils.ParamString(r, "id")size := utils.ParamInt(r, "size", 0)w.Header().Set("cache-control", "public, max-age=315360000")