Merge 1d15beb2eb6a7202f3b6fcf58a3549e0f986703b into a45adbbb2eb5a620173b5c1710017368abfb6be6

This commit is contained in:
Junker der Provinz 2026-10-17 01:30:22 +03:00 committed by GitHub
commit 7eef0fed51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 16 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/id"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@ -67,9 +66,10 @@ var _ = Describe("Folder", func() {
When("the folder has multiple subdirs", func() {
It("should return the correct folder ID", func() {
tests.SkipOnWindows("path separator bug (#TBD-path-sep-model)")
folderPath := filepath.FromSlash("/music/rock/metal")
expectedID := id.NewHash("1:rock/metal")
// IDs are persisted and hashed with the OS separator, so changing
// this on Windows would need a migration.
expectedID := id.NewHash("1:" + filepath.FromSlash("rock/metal"))
Expect(model.FolderID(lib, folderPath)).To(Equal(expectedID))
})
})
@ -77,8 +77,8 @@ var _ = Describe("Folder", func() {
Describe("NewFolder", func() {
It("should create a new SubFolder with the correct attributes", func() {
tests.SkipOnWindows("path separator bug (#TBD-path-sep-model)")
folderPath := filepath.FromSlash("rock/metal")
// The scanner passes fs.FS paths here, which use forward slashes on every OS.
folderPath := "rock/metal"
folder := model.NewFolder(lib, folderPath)
Expect(folder.LibraryID).To(Equal(lib.ID))

View File

@ -1,12 +1,12 @@
package model_test
import (
"path/filepath"
"time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/conf/configtest"
. "github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@ -477,9 +477,6 @@ var _ = Describe("MediaFiles", func() {
DescribeTable("generates correct output",
func(absolutePaths bool, expectedContent string) {
if absolutePaths {
tests.SkipOnWindows("path separator bug (#TBD-path-sep-model)")
}
result := mfs.ToM3U8("Multi Track", absolutePaths)
Expect(result).To(Equal(expectedContent))
},
@ -487,9 +484,10 @@ var _ = Describe("MediaFiles", func() {
false,
"#EXTM3U\n#PLAYLIST:Multi Track\n#EXTINF:120,Artist A - Song One\na/song1.mp3\n#EXTINF:241,Artist B - Song Two\nb/song2.mp3\n#EXTINF:90,Artist with Ümläuts - Song with \"quotes\" & ampersands\nspecial/file.mp3\n",
),
// AbsolutePath joins with the OS separator.
Entry("absolute paths",
true,
"#EXTM3U\n#PLAYLIST:Multi Track\n#EXTINF:120,Artist A - Song One\n/music/a/song1.mp3\n#EXTINF:241,Artist B - Song Two\n/music/b/song2.mp3\n#EXTINF:90,Artist with Ümläuts - Song with \"quotes\" & ampersands\n/música/special/file.mp3\n",
filepath.FromSlash("#EXTM3U\n#PLAYLIST:Multi Track\n#EXTINF:120,Artist A - Song One\n/music/a/song1.mp3\n#EXTINF:241,Artist B - Song Two\n/music/b/song2.mp3\n#EXTINF:90,Artist with Ümläuts - Song with \"quotes\" & ampersands\n/música/special/file.mp3\n"),
),
Entry("special characters",
false,
@ -500,7 +498,6 @@ var _ = Describe("MediaFiles", func() {
Context("path variations", func() {
It("handles different path structures", func() {
tests.SkipOnWindows("path separator bug (#TBD-path-sep-model)")
mfs = MediaFiles{
{Title: "Root", Artist: "Artist", Duration: 60, Path: "song.mp3", LibraryPath: "/lib"},
{Title: "Nested", Artist: "Artist", Duration: 60, Path: "deep/nested/song.mp3", LibraryPath: "/lib"},
@ -511,8 +508,8 @@ var _ = Describe("MediaFiles", func() {
Expect(relativeResult).To(ContainSubstring("deep/nested/song.mp3\n"))
absoluteResult := mfs.ToM3U8("Test", true)
Expect(absoluteResult).To(ContainSubstring("/lib/song.mp3\n"))
Expect(absoluteResult).To(ContainSubstring("/lib/deep/nested/song.mp3\n"))
Expect(absoluteResult).To(ContainSubstring(filepath.FromSlash("/lib/song.mp3\n")))
Expect(absoluteResult).To(ContainSubstring(filepath.FromSlash("/lib/deep/nested/song.mp3\n")))
})
})
})

View File

@ -8,7 +8,6 @@ import (
"github.com/navidrome/navidrome/conf/configtest"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/criteria"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@ -34,7 +33,6 @@ var _ = Describe("Playlist", func() {
}
})
It("generates the correct M3U format", func() {
tests.SkipOnWindows("path separator bug (#TBD-path-sep-model)")
expected := `#EXTM3U
#PLAYLIST:Mellow sunset
#EXTINF:378,Morcheeba feat. Kurt Wagner - What New York Couples Fight About
@ -46,7 +44,7 @@ var _ = Describe("Playlist", func() {
#EXTINF:164,Legião Urbana - On the Way Home
/music/library/Legião Urbana/Música p_ acampamentos/02-05 On the Way Home.mp3
`
Expect(pls.ToM3U8()).To(Equal(expected))
Expect(pls.ToM3U8()).To(Equal(filepath.FromSlash(expected)))
})
})