Skip to content

🎧 Your Personal Streaming Service

Fix artwork resolution when paths contains `:`. Fix #2137

Deluan9b81aa440318
diff --git a/core/artwork/artwork_internal_test.go b/core/artwork/artwork_internal_test.go
index c7def078f..d7b438aff 100644
--- a/core/artwork/artwork_internal_test.go
+++ b/core/artwork/artwork_internal_test.go
@@ -8,6 +8,7 @@ import (
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/conf/configtest"
+ "github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/tests"
@@ -34,7 +35,7 @@ var _ = Describe("Artwork", func() {
alOnlyExternal = model.Album{ID: "444", Name: "Only external", ImageFiles: "tests/fixtures/front.png"}
alExternalNotFound = model.Album{ID: "555", Name: "External not found", ImageFiles: "tests/fixtures/NON_EXISTENT.png"}
alMultipleCovers = model.Album{ID: "666", Name: "All options", EmbedArtPath: "tests/fixtures/test.mp3",
- ImageFiles: "tests/fixtures/cover.jpg:tests/fixtures/front.png",
+ ImageFiles: "tests/fixtures/cover.jpg" + consts.Zwsp + "tests/fixtures/front.png",
}
mfWithEmbed = model.MediaFile{ID: "22", Path: "tests/fixtures/test.mp3", HasCoverArt: true, AlbumID: "222"}
mfWithoutEmbed = model.MediaFile{ID: "44", Path: "tests/fixtures/test.ogg", AlbumID: "444"}
diff --git a/core/artwork/reader_artist.go b/core/artwork/reader_artist.go
index bbaeebef9..15181e415 100644
--- a/core/artwork/reader_artist.go
+++ b/core/artwork/reader_artist.go
@@ -13,6 +13,7 @@ import (
"github.com/Masterminds/squirrel"
"github.com/navidrome/navidrome/conf"
+ "github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
@@ -49,12 +50,12 @@ func newArtistReader(ctx context.Context, artwork *artwork, artID model.ArtworkI
var paths []string
for _, al := range als {
files = append(files, al.ImageFiles)
- paths = append(paths, filepath.SplitList(al.Paths)...)
+ paths = append(paths, splitList(al.Paths)...)
if a.cacheKey.lastUpdate.Before(al.UpdatedAt) {
a.cacheKey.lastUpdate = al.UpdatedAt
}
}
- a.files = strings.Join(files, string(filepath.ListSeparator))
+ a.files = strings.Join(files, consts.Zwsp)
a.artistFolder = utils.LongestCommonPrefix(paths)
if !strings.HasSuffix(a.artistFolder, string(filepath.Separator)) {
a.artistFolder, _ = filepath.Split(a.artistFolder)
diff --git a/core/artwork/sources.go b/core/artwork/sources.go
index a4fda337b..832901f22 100644
--- a/core/artwork/sources.go
+++ b/core/artwork/sources.go
@@ -52,9 +52,13 @@ func (f sourceFunc) String() string {
return name
}
+func splitList(s string) []string {
+ return strings.Split(s, consts.Zwsp)
+}
+
func fromExternalFile(ctx context.Context, files string, pattern string) sourceFunc {
return func() (io.ReadCloser, string, error) {
- for _, file := range filepath.SplitList(files) {
+ for _, file := range splitList(files) {
_, name := filepath.Split(file)
match, err := filepath.Match(pattern, strings.ToLower(name))
if err != nil {
diff --git a/db/migration/20230112111457_add_album_paths.go b/db/migration/20230112111457_add_album_paths.go
index 4f32106e4..baebae696 100644
--- a/db/migration/20230112111457_add_album_paths.go
+++ b/db/migration/20230112111457_add_album_paths.go
@@ -59,7 +59,7 @@ func upAddAlbumPathsDirs(filePaths string) string {
}
slices.Sort(dirs)
dirs = slices.Compact(dirs)
- return strings.Join(dirs, string(filepath.ListSeparator))
+ return strings.Join(dirs, consts.Zwsp)
}
func downAddAlbumPaths(tx *sql.Tx) error {
diff --git a/model/mediafile.go b/model/mediafile.go
index 7c4d1d52b..da74ec970 100644
--- a/model/mediafile.go
+++ b/model/mediafile.go
@@ -151,7 +151,7 @@ func (mfs MediaFiles) ToAlbum() Album {
a.EmbedArtPath = m.Path
}
}
- a.Paths = strings.Join(mfs.Dirs(), string(filepath.ListSeparator))
+ a.Paths = strings.Join(mfs.Dirs(), consts.Zwsp)
comments = slices.Compact(comments)
if len(comments) == 1 {
a.Comment = comments[0]
diff --git a/model/mediafile_test.go b/model/mediafile_test.go
index c58f923a5..f21b6a099 100644
--- a/model/mediafile_test.go
+++ b/model/mediafile_test.go
@@ -5,6 +5,7 @@ import (
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/conf/configtest"
+ "github.com/navidrome/navidrome/consts"
. "github.com/navidrome/navidrome/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@@ -52,7 +53,7 @@ var _ = Describe("MediaFiles", func() {
Expect(album.CatalogNum).To(Equal("CatalogNum"))
Expect(album.Compilation).To(BeTrue())
Expect(album.EmbedArtPath).To(Equal("/music2/file2.mp3"))
- Expect(album.Paths).To(Equal("/music1:/music2"))
+ Expect(album.Paths).To(Equal("/music1" + consts.Zwsp + "/music2"))
})
})
Context("Aggregated attributes", func() {
diff --git a/scanner/refresher.go b/scanner/refresher.go
index dfbf72b59..2d8a8da55 100644
--- a/scanner/refresher.go
+++ b/scanner/refresher.go
@@ -8,6 +8,7 @@ import (
"time"
"github.com/Masterminds/squirrel"
+ "github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/core/artwork"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
@@ -121,7 +122,7 @@ func (r *refresher) getImageFiles(dirs []string) (string, time.Time) {
updatedAt = stats.ImagesUpdatedAt
}
}
- return strings.Join(imageFiles, string(filepath.ListSeparator)), updatedAt
+ return strings.Join(imageFiles, consts.Zwsp), updatedAt
}
func (r *refresher) refreshArtists(ctx context.Context, ids ...string) error {