Skip to content

Commit

Permalink
Fix forceRescan not re-importing all tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jul 19, 2021
1 parent 44e7502 commit 882b02c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scanner/tag_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time, prog
ctx = s.withAdminUser(ctx)
start := time.Now()

// Special case: if lastModifiedSInce is zero, re-import all files
fullScan := lastModifiedSince.IsZero()

allDBDirs, err := s.getDBDirTree(ctx)
if err != nil {
return 0, err
Expand All @@ -93,7 +96,7 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time, prog
if s.folderHasChanged(ctx, folderStats, allDBDirs, lastModifiedSince) {
changedDirs = append(changedDirs, folderStats.Path)
log.Debug("Processing changed folder", "dir", folderStats.Path)
err := s.processChangedDir(ctx, folderStats.Path)
err := s.processChangedDir(ctx, folderStats.Path, fullScan)
if err != nil {
log.Error("Error updating folder in the DB", "dir", folderStats.Path, err)
}
Expand Down Expand Up @@ -231,7 +234,7 @@ func (s *TagScanner) processDeletedDir(ctx context.Context, dir string) error {
return err
}

func (s *TagScanner) processChangedDir(ctx context.Context, dir string) error {
func (s *TagScanner) processChangedDir(ctx context.Context, dir string, fullScan bool) error {
start := time.Now()
buffer := newRefreshBuffer(ctx, s.ds)

Expand Down Expand Up @@ -270,7 +273,7 @@ func (s *TagScanner) processChangedDir(ctx context.Context, dir string) error {
filesToUpdate = append(filesToUpdate, filePath)
s.cnt.added++
}
if ok && info.ModTime().After(c.UpdatedAt) {
if ok && (info.ModTime().After(c.UpdatedAt) || fullScan) {
filesToUpdate = append(filesToUpdate, filePath)
s.cnt.updated++
}
Expand Down

0 comments on commit 882b02c

Please sign in to comment.