refactor(scanner): make the watcher a little easier to reason about (#394)

* add a test for symlinks escaping defined music paths

* refactor(scanner): make the watcher a little easier to reason about
This commit is contained in:
Senan Kelly
2023-10-24 23:57:42 +01:00
committed by GitHub
parent cae37255d6
commit c947404923
3 changed files with 76 additions and 72 deletions

View File

@@ -487,6 +487,23 @@ func TestSymlinkedSubdiscs(t *testing.T) {
assert.NotZero(t, info.ModTime()) // track resolves
}
func TestSymlinkEscapesMusicDirs(t *testing.T) {
t.Parallel()
m := mockfs.NewWithDirs(t, []string{"scandir"})
require.NoError(t, os.MkdirAll(filepath.Join(m.TmpDir(), "otherdir", "artist", "album-test"), os.ModePerm))
require.NoError(t, os.Symlink(
filepath.Join(m.TmpDir(), "otherdir", "artist"),
filepath.Join(m.TmpDir(), "scandir", "artist"),
))
m.ScanAndClean()
var albums []*db.Album
require.NoError(t, m.DB().Find(&albums).Error)
require.Len(t, albums, 3)
}
func TestTagErrors(t *testing.T) {
t.Parallel()
m := mockfs.New(t)