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

@@ -31,6 +31,7 @@ import (
type Options struct {
DB *db.DB
MusicPaths []ctrlsubsonic.MusicPath
ExcludePattern string
PodcastPath string
CacheAudioPath string
CoverCachePath string
@@ -51,7 +52,7 @@ type Server struct {
func New(opts Options) (*Server, error) {
tagger := &tags.TagReader{}
scanner := scanner.New(ctrlsubsonic.PathsOf(opts.MusicPaths), opts.DB, opts.GenreSplit, tagger)
scanner := scanner.New(ctrlsubsonic.PathsOf(opts.MusicPaths), opts.DB, opts.GenreSplit, tagger, opts.ExcludePattern)
base := &ctrlbase.Controller{
DB: opts.DB,
ProxyPrefix: opts.ProxyPrefix,
@@ -94,7 +95,7 @@ func New(opts Options) (*Server, error) {
ctrlSubsonic := &ctrlsubsonic.Controller{
Controller: base,
MusicPaths: opts.MusicPaths,
PodcastsPath: opts.PodcastPath,
PodcastsPath: opts.PodcastPath,
CacheAudioPath: opts.CacheAudioPath,
CoverCachePath: opts.CoverCachePath,
Scrobblers: []scrobble.Scrobbler{&lastfm.Scrobbler{DB: opts.DB}, &listenbrainz.Scrobbler{}},