Fix forceRescan not re-importing all tracks
This commit is contained in:
@@ -72,6 +72,9 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time, prog
|
|||||||
ctx = s.withAdminUser(ctx)
|
ctx = s.withAdminUser(ctx)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
// Special case: if lastModifiedSInce is zero, re-import all files
|
||||||
|
fullScan := lastModifiedSince.IsZero()
|
||||||
|
|
||||||
allDBDirs, err := s.getDBDirTree(ctx)
|
allDBDirs, err := s.getDBDirTree(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -93,7 +96,7 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time, prog
|
|||||||
if s.folderHasChanged(ctx, folderStats, allDBDirs, lastModifiedSince) {
|
if s.folderHasChanged(ctx, folderStats, allDBDirs, lastModifiedSince) {
|
||||||
changedDirs = append(changedDirs, folderStats.Path)
|
changedDirs = append(changedDirs, folderStats.Path)
|
||||||
log.Debug("Processing changed folder", "dir", 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 {
|
if err != nil {
|
||||||
log.Error("Error updating folder in the DB", "dir", folderStats.Path, err)
|
log.Error("Error updating folder in the DB", "dir", folderStats.Path, err)
|
||||||
}
|
}
|
||||||
@@ -231,7 +234,7 @@ func (s *TagScanner) processDeletedDir(ctx context.Context, dir string) error {
|
|||||||
return err
|
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()
|
start := time.Now()
|
||||||
buffer := newRefreshBuffer(ctx, s.ds)
|
buffer := newRefreshBuffer(ctx, s.ds)
|
||||||
|
|
||||||
@@ -270,7 +273,7 @@ func (s *TagScanner) processChangedDir(ctx context.Context, dir string) error {
|
|||||||
filesToUpdate = append(filesToUpdate, filePath)
|
filesToUpdate = append(filesToUpdate, filePath)
|
||||||
s.cnt.added++
|
s.cnt.added++
|
||||||
}
|
}
|
||||||
if ok && info.ModTime().After(c.UpdatedAt) {
|
if ok && (info.ModTime().After(c.UpdatedAt) || fullScan) {
|
||||||
filesToUpdate = append(filesToUpdate, filePath)
|
filesToUpdate = append(filesToUpdate, filePath)
|
||||||
s.cnt.updated++
|
s.cnt.updated++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user