Add scan option to force gallery zip rescan (#4113)

* Add scan option to force rescan
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
CJ
2024-05-19 22:52:36 -05:00
committed by GitHub
parent 5ba1ea8fbc
commit 0fa71be697
5 changed files with 24 additions and 6 deletions

View File

@@ -134,6 +134,9 @@ type ScanOptions struct {
HandlerRequiredFilters []Filter
ParallelTasks int
// When true files in path will be rescanned even if they haven't changed
Rescan bool
}
// Scan starts the scanning process.
@@ -1023,14 +1026,20 @@ func (s *scanJob) onExistingFile(ctx context.Context, f scanFile, existing model
fileModTime := f.ModTime
updated := !fileModTime.Equal(base.ModTime)
forceRescan := s.options.Rescan
if !updated {
if !updated && !forceRescan {
return s.onUnchangedFile(ctx, f, existing)
}
oldBase := *base
logger.Infof("%s has been updated: rescanning", path)
if !updated && forceRescan {
logger.Infof("rescanning %s", path)
} else {
logger.Infof("%s has been updated: rescanning", path)
}
base.ModTime = fileModTime
base.Size = f.Size
base.UpdatedAt = time.Now()