feat(scan): always scan downloads + organize dirs, deduplicate child paths

ResolveScanPaths() collects downloads.dir, organize.movies_dir,
organize.tv_shows_dir, and library.scan_path (if set), then removes
paths that are subdirectories of a parent already in the list.

This ensures the daemon and CLI scan all configured dirs without
relying solely on scan_path being set.
This commit is contained in:
Deivid Soto 2026-04-10 11:46:20 +02:00
parent b2ed81ee74
commit db316726fd
3 changed files with 122 additions and 47 deletions

View file

@ -41,11 +41,16 @@ to see available quality upgrades.`,
}
if len(args) == 0 {
cfg := loadConfig()
if cfg.Library.ScanPath != "" {
args = append(args, cfg.Library.ScanPath)
} else {
return fmt.Errorf("usage: unarr scan <path>\n\nProvide a media folder to scan")
paths := library.ResolveScanPaths(cfg.Download.Dir, cfg.Organize.MoviesDir, cfg.Organize.TVShowsDir, cfg.Library.ScanPath)
if len(paths) == 0 {
return fmt.Errorf("usage: unarr scan <path>\n\nNo scan paths configured. Provide a path or set up downloads.dir via 'unarr init'")
}
for _, p := range paths {
if err := runScan(p, workers, ffprobe, noSync); err != nil {
return err
}
}
return nil
}
return runScan(args[0], workers, ffprobe, noSync)
},