mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-18 07:30:29 +00:00
Merge 57dd97e910c3d62fcf9fef087a7a27e41a32ebaf into a45adbbb2eb5a620173b5c1710017368abfb6be6
This commit is contained in:
commit
9d0f91beff
@ -226,7 +226,6 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
})
|
||||
|
||||
It("should re-enqueue the album artwork even though it already resolved", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
Expect(runScanner(ctx, true)).To(Succeed())
|
||||
|
||||
resolveQueuedArtwork()
|
||||
@ -245,7 +244,6 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
})
|
||||
|
||||
It("should update the album", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
Expect(runScanner(ctx, true)).To(Succeed())
|
||||
|
||||
albums, err := ds.Album().GetAll(ctx, model.QueryOptions{Filters: squirrel.Eq{"album.name": "Help!"}})
|
||||
@ -533,7 +531,6 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
var beatlesMBID = uuid.NewString()
|
||||
|
||||
BeforeEach(func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
By("Having two MP3 albums")
|
||||
beatles := _t{
|
||||
"artist": "The Beatles",
|
||||
@ -600,6 +597,7 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
})
|
||||
|
||||
It("detects a file was moved to a different folder", func() {
|
||||
tests.SkipOnWindows("coarse clock can give a new track the scan start time, so the move is missed")
|
||||
By("Storing the original ID")
|
||||
original, err := findByPath("The Beatles/Revolver/02 - Eleanor Rigby.mp3")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@ -632,6 +630,7 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
})
|
||||
|
||||
It("detects a move after a scan is interrupted by an error", func() {
|
||||
tests.SkipOnWindows("coarse clock can give a new track the scan start time, so the move is missed")
|
||||
By("Storing the original ID")
|
||||
By("Moving the file to a different folder")
|
||||
fsys.Move("The Beatles/Revolver/01 - Taxman.mp3", "The Beatles/Help!/01 - Taxman.mp3")
|
||||
@ -659,6 +658,7 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
})
|
||||
|
||||
It("detects file format upgrades", func() {
|
||||
tests.SkipOnWindows("coarse clock can give a new track the scan start time, so the move is missed")
|
||||
By("Storing the original ID")
|
||||
original, err := findByPath("The Beatles/Revolver/02 - Eleanor Rigby.mp3")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@ -1201,7 +1201,6 @@ var _ = Describe("Scanner", Ordered, func() {
|
||||
})
|
||||
|
||||
It("should update artist stats during quick scans when new albums are added", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
// Don't use the mocked artist repo for this test - we need the real one
|
||||
ds.MockedArtist = nil
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -250,6 +251,9 @@ func (w *watcher) processLibraryEvents(ctx context.Context, lib *model.Library,
|
||||
log.Error(ctx, "Error getting relative path", "libraryID", lib.ID, "absolutePath", absLibPath, "path", path, err)
|
||||
continue
|
||||
}
|
||||
// filepath.Rel returns OS separators, but fs.FS lookups and scan targets
|
||||
// need "/" (os.DirFS rejects "\" on Windows).
|
||||
path = filepath.ToSlash(path)
|
||||
|
||||
if isIgnoredPath(ctx, fsys, path) {
|
||||
log.Trace(ctx, "Ignoring change", "libraryID", lib.ID, "path", path)
|
||||
@ -282,13 +286,13 @@ func (w *watcher) processLibraryEvents(ctx context.Context, lib *model.Library,
|
||||
// resolveFolderPath takes a path (which may be a file or directory) and returns
|
||||
// the folder path to scan. If the path is a file, it walks up to find the parent
|
||||
// directory. Returns empty string if the path should scan the library root.
|
||||
func resolveFolderPath(fsys fs.FS, path string) string {
|
||||
func resolveFolderPath(fsys fs.FS, p string) string {
|
||||
// Handle root paths immediately
|
||||
if path == "." || path == "" {
|
||||
if p == "." || p == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
folderPath := path
|
||||
folderPath := p
|
||||
for {
|
||||
info, err := fs.Stat(fsys, folderPath)
|
||||
if err == nil && info.IsDir() {
|
||||
@ -299,13 +303,12 @@ func resolveFolderPath(fsys fs.FS, path string) string {
|
||||
// Reached root, scan entire library
|
||||
return ""
|
||||
}
|
||||
// Walk up the tree
|
||||
dir, _ := filepath.Split(folderPath)
|
||||
if dir == "" || dir == "." {
|
||||
// Walk up the tree with path.Dir, since fs.FS paths use "/" on every OS
|
||||
parent := path.Dir(folderPath)
|
||||
if parent == "." || parent == folderPath {
|
||||
return ""
|
||||
}
|
||||
// Remove trailing slash
|
||||
folderPath = filepath.Clean(dir)
|
||||
folderPath = parent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -382,7 +382,6 @@ var _ = Describe("Watcher", func() {
|
||||
})
|
||||
|
||||
It("should NOT send notification when nested ignored folder is deleted", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
startEventProcessing()
|
||||
|
||||
// Simulate deletion of music/rock/artist/temp (matches **/temp)
|
||||
@ -396,7 +395,6 @@ var _ = Describe("Watcher", func() {
|
||||
})
|
||||
|
||||
It("should send notification for non-ignored nested folder", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
startEventProcessing()
|
||||
|
||||
// Simulate change in music/rock/artist (doesn't match any pattern)
|
||||
@ -421,7 +419,6 @@ var _ = Describe("Watcher", func() {
|
||||
})
|
||||
|
||||
It("should NOT send notification for file changes in ignored folders", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
startEventProcessing()
|
||||
|
||||
// Simulate file change in rock/_TEMP/file.mp3
|
||||
@ -504,13 +501,11 @@ var _ = Describe("resolveFolderPath", func() {
|
||||
})
|
||||
|
||||
It("walks up to parent directory when given a file path", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
result := resolveFolderPath(mockFS, "artist1/album1/track1.mp3")
|
||||
Expect(result).To(Equal("artist1/album1"))
|
||||
})
|
||||
|
||||
It("walks up multiple levels if needed", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
result := resolveFolderPath(mockFS, "artist1/album1/nonexistent/file.mp3")
|
||||
Expect(result).To(Equal("artist1/album1"))
|
||||
})
|
||||
@ -531,7 +526,6 @@ var _ = Describe("resolveFolderPath", func() {
|
||||
})
|
||||
|
||||
It("handles nested file paths correctly", func() {
|
||||
tests.SkipOnWindows("path separator bug (#TBD-path-sep-scanner)")
|
||||
result := resolveFolderPath(mockFS, "artist1/album2/song.flac")
|
||||
Expect(result).To(Equal("artist1/album2"))
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user