feat(scanner): add a new option for excluding paths based on a regexp

* Exclude paths based on new exclude pattern option

* Add test for excluded paths

* Add exclude pattern option to docs

* Set exclude regexp only if given argument is set

* Update scanner/scanner.go

---------

Co-authored-by: Senan Kelly <senan@senan.xyz>
This commit is contained in:
Gregor Zurowski
2023-05-06 19:03:11 +02:00
committed by GitHub
parent 74de06430a
commit 1d3877668f
6 changed files with 74 additions and 22 deletions

View File

@@ -62,6 +62,12 @@ func main() {
confShowVersion := set.Bool("version", false, "show gonic version")
_ = set.String("config-path", "", "path to config (optional)")
confExcludePatterns := set.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)")
if _, err := regexp.Compile(*confExcludePatterns); err != nil {
log.Fatalf("invalid exclude pattern: %v\n", err)
}
if err := ff.Parse(set, os.Args[1:],
ff.WithConfigFileFlag("config-path"),
ff.WithConfigFileParser(ff.PlainParser),
@@ -125,6 +131,7 @@ func main() {
server, err := server.New(server.Options{
DB: dbc,
MusicPaths: musicPaths,
ExcludePattern: *confExcludePatterns,
CacheAudioPath: cacheDirAudio,
CoverCachePath: cacheDirCovers,
PodcastPath: *confPodcastPath,