🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Stop tag_scanner when waltDirTree is interrupted by errors
Deluan145a5708ca77
diff --git a/scanner/tag_scanner.go b/scanner/tag_scanner.goindex 7e4fda339..c5dad1c33 100644--- a/scanner/tag_scanner.go+++ b/scanner/tag_scanner.go@@ -80,7 +80,7 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time) errovar changedDirs []strings.cnt = &counters{}- foldersFound := s.getRootFolderWalker(ctx)+ foldersFound, walkerError := s.getRootFolderWalker(ctx)for {folderStats, more := <-foldersFoundif !more {@@ -98,6 +98,11 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time) erro}}+ if err := <-walkerError; err != nil {+ log.Error("Scan was interrupted by error. See errors above", err)+ return err+ }+// If the media folder is empty, abort to avoid deleting all dataif len(allFSDirs) <= 1 {log.Error(ctx, "Media Folder is empty. Aborting scan.", "folder", s.rootFolder)@@ -143,17 +148,20 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time) erroreturn err}-func (s *TagScanner) getRootFolderWalker(ctx context.Context) walkResults {+func (s *TagScanner) getRootFolderWalker(ctx context.Context) (walkResults, chan error) {start := time.Now()log.Trace(ctx, "Loading directory tree from music folder", "folder", s.rootFolder)results := make(chan dirStats, 5000)+ walkerError := make(chan error)go func() {- if err := walkDirTree(ctx, s.rootFolder, results); err != nil {- log.Error("Scan was interrupted by error", err)+ err := walkDirTree(ctx, s.rootFolder, results)+ if err != nil {+ log.Error("There were errors reading directories from filesystem", err)}+ walkerError <- errlog.Debug("Finished reading directories from filesystem", "elapsed", time.Since(start))}()- return results+ return results, walkerError}func (s *TagScanner) getDBDirTree(ctx context.Context) (map[string]struct{}, error) {