From 5fb1db60314ee800cb6ead9a9f7100da3c206661 Mon Sep 17 00:00:00 2001 From: Deluan Date: Wed, 12 Mar 2025 18:13:22 -0400 Subject: [PATCH] fix(scanner): watcher not working with relative MusicFolder Signed-off-by: Deluan --- scanner/watcher.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scanner/watcher.go b/scanner/watcher.go index 3090966a7..bf4f7f9d0 100644 --- a/scanner/watcher.go +++ b/scanner/watcher.go @@ -101,22 +101,27 @@ func watchLib(ctx context.Context, lib model.Library, watchChan chan struct{}) { log.Error(ctx, "Watcher: Error watching library", "library", lib.ID, "path", lib.Path, err) return } - log.Info(ctx, "Watcher started", "library", lib.ID, "path", lib.Path) + absLibPath, err := filepath.Abs(lib.Path) + if err != nil { + log.Error(ctx, "Watcher: Error converting lib.Path to absolute", "library", lib.ID, "path", lib.Path, err) + return + } + log.Info(ctx, "Watcher started", "library", lib.ID, "libPath", lib.Path, "absoluteLibPath", absLibPath) for { select { case <-ctx.Done(): return case path := <-c: - path, err = filepath.Rel(lib.Path, path) + path, err = filepath.Rel(absLibPath, path) if err != nil { - log.Error(ctx, "Watcher: Error getting relative path", "library", lib.ID, "path", path, err) + log.Error(ctx, "Watcher: Error getting relative path", "library", lib.ID, "libPath", absLibPath, "path", path, err) continue } if isIgnoredPath(ctx, fsys, path) { log.Trace(ctx, "Watcher: Ignoring change", "library", lib.ID, "path", path) continue } - log.Trace(ctx, "Watcher: Detected change", "library", lib.ID, "path", path) + log.Trace(ctx, "Watcher: Detected change", "library", lib.ID, "path", path, "libPath", absLibPath) watchChan <- struct{}{} } }