Skip to content

🎧 Your Personal Streaming Service

Fix regression: Show artwork in Music Stash when browsing by folder

Deluan0e16d7cfbb4b
diff --git a/core/artwork.go b/core/artwork.go
index 4cf20c535..d37d98666 100644
--- a/core/artwork.go
+++ b/core/artwork.go
@@ -90,17 +90,25 @@ func (c *artwork) getImagePath(ctx context.Context, id string) (path string, las
}
log.Trace(ctx, "Looking for media file art", "id", id)
- // if id is a mediafile cover id
+
+ // Check if id is a mediaFile cover id
var mf *model.MediaFile
mf, err = c.ds.MediaFile(ctx).Get(id)
+
+ // If it is not, may be an albumId
+ if err == model.ErrNotFound {
+ return c.getImagePath(ctx, "al-"+id)
+ }
if err != nil {
return
}
+
+ // If it is a mediaFile and it has cover art, return it
if mf.HasCoverArt {
return mf.Path, mf.UpdatedAt, nil
}
- // if the mediafile does not have a coverArt, fallback to the album cover
+ // if the mediaFile does not have a coverArt, fallback to the album cover
log.Trace(ctx, "Media file does not contain art. Falling back to album art", "id", id, "albumId", "al-"+mf.AlbumID)
return c.getImagePath(ctx, "al-"+mf.AlbumID)
}
diff --git a/core/artwork_test.go b/core/artwork_test.go
index 3c69c3e74..a8a0d41d9 100644
--- a/core/artwork_test.go
+++ b/core/artwork_test.go
@@ -101,6 +101,16 @@ var _ = Describe("Artwork", func() {
Expect(format).To(Equal("jpeg"))
})
+ It("retrieves the album artwork by album id", func() {
+ buf := new(bytes.Buffer)
+
+ Expect(artwork.Get(ctx, "222", 0, buf)).To(BeNil())
+
+ _, format, err := image.Decode(bytes.NewReader(buf.Bytes()))
+ Expect(err).To(BeNil())
+ Expect(format).To(Equal("jpeg"))
+ })
+
It("resized artwork art as requested", func() {
buf := new(bytes.Buffer)