fix(scanner): update lib.LastScanAt on each rescan (#3313)

This commit is contained in:
Deluan Quintão
2024-09-26 06:16:27 -04:00
committed by GitHub
parent d31952f469
commit 76614b8f16
2 changed files with 20 additions and 14 deletions
+15 -9
View File
@@ -25,20 +25,22 @@ import (
)
type TagScanner struct {
lib model.Library
// Dependencies
ds model.DataStore
plsSync *playlistImporter
cnt *counters
mapper *MediaFileMapper
playlists core.Playlists
cacheWarmer artwork.CacheWarmer
// Internal state
lib model.Library
cnt *counters
mapper *MediaFileMapper
}
func NewTagScanner(lib model.Library, ds model.DataStore, playlists core.Playlists, cacheWarmer artwork.CacheWarmer) FolderScanner {
func NewTagScanner(ds model.DataStore, playlists core.Playlists, cacheWarmer artwork.CacheWarmer) FolderScanner {
s := &TagScanner{
lib: lib,
plsSync: newPlaylistImporter(ds, playlists, cacheWarmer, lib.Path),
ds: ds,
cacheWarmer: cacheWarmer,
playlists: playlists,
}
metadata.LogExtractors()
@@ -77,10 +79,13 @@ const (
// - If the playlist is not in the DB, import it, setting sync = true
// - If the playlist is in the DB and sync == true, import it, or else skip it
// Delete all empty albums, delete all empty artists, clean-up playlists
func (s *TagScanner) Scan(ctx context.Context, fullScan bool, progress chan uint32) (int64, error) {
func (s *TagScanner) Scan(ctx context.Context, lib model.Library, fullScan bool, progress chan uint32) (int64, error) {
ctx = auth.WithAdminUser(ctx, s.ds)
start := time.Now()
// Update internal copy of Library
s.lib = lib
// Special case: if LastScanAt is zero, re-import all files
fullScan = fullScan || s.lib.LastScanAt.IsZero()
@@ -164,7 +169,8 @@ func (s *TagScanner) Scan(ctx context.Context, fullScan bool, progress chan uint
log.Warn("Playlists will not be imported, as there are no admin users yet, "+
"Please create an admin user first, and then update the playlists for them to be imported", "dir", dir)
} else {
s.cnt.playlists = s.plsSync.processPlaylists(ctx, dir)
plsSync := newPlaylistImporter(s.ds, s.playlists, s.cacheWarmer, lib.Path)
s.cnt.playlists = plsSync.processPlaylists(ctx, dir)
}
}
}