Rename DevFastAccessCoverArt to EnableMediaFileCoverArt

This commit is contained in:
Deluan 2022-12-27 14:30:00 -05:00 committed by Deluan Quintão
parent 722a00cacf
commit 332900774d
6 changed files with 14 additions and 17 deletions

View file

@ -1,8 +1,6 @@
package model_test
import (
"time"
"github.com/navidrome/navidrome/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -10,25 +8,23 @@ import (
var _ = Describe("ParseArtworkID()", func() {
It("parses album artwork ids", func() {
id, err := model.ParseArtworkID("al-1234-ff")
id, err := model.ParseArtworkID("al-1234")
Expect(err).ToNot(HaveOccurred())
Expect(id.Kind).To(Equal(model.KindAlbumArtwork))
Expect(id.ID).To(Equal("1234"))
Expect(id.LastUpdate).To(Equal(time.Unix(255, 0)))
})
It("parses media file artwork ids", func() {
id, err := model.ParseArtworkID("mf-a6f8d2b1-ffff")
id, err := model.ParseArtworkID("mf-a6f8d2b1")
Expect(err).ToNot(HaveOccurred())
Expect(id.Kind).To(Equal(model.KindMediaFileArtwork))
Expect(id.ID).To(Equal("a6f8d2b1"))
Expect(id.LastUpdate).To(Equal(time.Unix(65535, 0)))
})
It("fails to parse malformed ids", func() {
_, err := model.ParseArtworkID("a6f8d2b1")
Expect(err).To(MatchError("invalid artwork id"))
})
It("fails to parse ids with invalid kind", func() {
_, err := model.ParseArtworkID("xx-a6f8d2b1-ff")
_, err := model.ParseArtworkID("xx-a6f8d2b1")
Expect(err).To(MatchError("invalid artwork kind"))
})
})

View file

@ -70,7 +70,7 @@ func (mf MediaFile) ContentType() string {
func (mf MediaFile) CoverArtID() ArtworkID {
// If it has a cover art, return it (if feature is disabled, skip)
if mf.HasCoverArt && !conf.Server.DevFastAccessCoverArt {
if mf.HasCoverArt && conf.Server.EnableMediaFileCoverArt {
return artworkIDFromMediaFile(mf)
}
// if it does not have a coverArt, fallback to the album cover

View file

@ -225,7 +225,7 @@ var _ = Describe("MediaFiles", func() {
var _ = Describe("MediaFile", func() {
BeforeEach(func() {
DeferCleanup(configtest.SetupConfig())
conf.Server.DevFastAccessCoverArt = false
conf.Server.EnableMediaFileCoverArt = true
})
Describe(".CoverArtId()", func() {
It("returns its own id if it HasCoverArt", func() {
@ -240,8 +240,8 @@ var _ = Describe("MediaFile", func() {
Expect(id.Kind).To(Equal(KindAlbumArtwork))
Expect(id.ID).To(Equal(mf.AlbumID))
})
It("returns its album id if DevFastAccessCoverArt is enabled", func() {
conf.Server.DevFastAccessCoverArt = true
It("returns its album id if EnableMediaFileCoverArt is disabled", func() {
conf.Server.EnableMediaFileCoverArt = false
mf := MediaFile{ID: "111", AlbumID: "1", HasCoverArt: true}
id := mf.CoverArtID()
Expect(id.Kind).To(Equal(KindAlbumArtwork))