🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Small refactorings, better var/function names
Deluan4e4fcb2304a1
diff --git a/scanner/tag_scanner_2.go b/scanner/tag_scanner_2.goindex a5cadae00..61a1a78da 100644--- a/scanner/tag_scanner_2.go+++ b/scanner/tag_scanner_2.go@@ -50,7 +50,7 @@ func (s *TagScanner2) Scan(ctx context.Context, lastModifiedSince time.Time) errctx = s.withAdminUser(ctx)start := time.Now()- allDirs, err := s.getDirTree(ctx)+ allFSDirs, err := s.getDirTree(ctx)if err != nil {return err}@@ -60,8 +60,8 @@ func (s *TagScanner2) Scan(ctx context.Context, lastModifiedSince time.Time) errreturn err}- changedDirs := s.getChangedDirs(ctx, allDirs, allDBDirs, lastModifiedSince)- deletedDirs := s.getDeletedDirs(ctx, allDirs, allDBDirs)+ changedDirs := s.getChangedDirs(ctx, allFSDirs, allDBDirs, lastModifiedSince)+ deletedDirs := s.getDeletedDirs(ctx, allFSDirs, allDBDirs)if len(changedDirs)+len(deletedDirs) == 0 {log.Debug(ctx, "No changes found in Music Folder", "folder", s.rootFolder)@@ -94,7 +94,7 @@ func (s *TagScanner2) Scan(ctx context.Context, lastModifiedSince time.Time) erru, _ := request.UserFrom(ctx)plsCount := 0for _, dir := range changedDirs {- info := allDirs[dir]+ info := allFSDirs[dir]if info.hasPlaylist {if !u.IsAdmin {log.Warn("Playlists will not be imported, as there are no admin users yet, "+@@ -141,18 +141,14 @@ func (s *TagScanner2) getDBDirTree(ctx context.Context) (map[string]struct{}, erreturn resp, nil}-func (s *TagScanner2) getChangedDirs(ctx context.Context, dirs dirMap, dbDirs map[string]struct{}, lastModified time.Time) []string {+func (s *TagScanner2) getChangedDirs(ctx context.Context, fsDirs dirMap, dbDirs map[string]struct{}, lastModified time.Time) []string {start := time.Now()log.Trace(ctx, "Checking for changed folders")var changed []string- for d, info := range dirs {+ for d, info := range fsDirs {_, inDB := dbDirs[d]- if !inDB && (info.hasAudioFiles) {- changed = append(changed, d)- continue- }- if info.modTime.After(lastModified) {+ if (!inDB && (info.hasAudioFiles)) || info.modTime.After(lastModified) {changed = append(changed, d)}}@@ -162,13 +158,13 @@ func (s *TagScanner2) getChangedDirs(ctx context.Context, dirs dirMap, dbDirs mareturn changed}-func (s *TagScanner2) getDeletedDirs(ctx context.Context, allDirs dirMap, dbDirs map[string]struct{}) []string {+func (s *TagScanner2) getDeletedDirs(ctx context.Context, fsDirs dirMap, dbDirs map[string]struct{}) []string {start := time.Now()log.Trace(ctx, "Checking for deleted folders")var deleted []stringfor d := range dbDirs {- if _, ok := allDirs[d]; !ok {+ if _, ok := fsDirs[d]; !ok {deleted = append(deleted, d)}}diff --git a/server/subsonic/media_annotation.go b/server/subsonic/media_annotation.goindex 9223dbde6..35fb3d4a2 100644--- a/server/subsonic/media_annotation.go+++ b/server/subsonic/media_annotation.go@@ -59,7 +59,7 @@ func (c *MediaAnnotationController) Star(w http.ResponseWriter, r *http.Request)ids = append(ids, albumIds...)ids = append(ids, artistIds...)- err := c.star(r.Context(), true, ids...)+ err := c.setStar(r.Context(), true, ids...)if err != nil {return nil, err}@@ -67,7 +67,7 @@ func (c *MediaAnnotationController) Star(w http.ResponseWriter, r *http.Request)return NewResponse(), nil}-func (c *MediaAnnotationController) star(ctx context.Context, starred bool, ids ...string) error {+func (c *MediaAnnotationController) setStar(ctx context.Context, starred bool, ids ...string) error {if len(ids) == 0 {return nil}@@ -94,7 +94,7 @@ func (c *MediaAnnotationController) Unstar(w http.ResponseWriter, r *http.Requesids = append(ids, albumIds...)ids = append(ids, artistIds...)- err := c.star(r.Context(), false, ids...)+ err := c.setStar(r.Context(), false, ids...)if err != nil {return nil, err}