fix: start index build only after ALL library scans complete
FullRescan scans the first library directly, then queues the rest. The PostScan hook was restarting the index build after the FIRST library, which starved the queued libraries for DB access — they never scanned, leaving the library with only 6 tracks. Fix: move StartIndexBuild to the OnAllScansComplete hook, which fires when drainQueue finds no more libraries to scan. This ensures ALL libraries finish scanning before the index build starts. For startup soft scans: if no scans were queued (library unchanged), start the index build directly. If scans WERE queued, the hook handles it. Added OnAllScansComplete callback to ScanHooks. Called from drainQueue when the scan pipeline goes idle.
This commit is contained in:
@@ -254,7 +254,12 @@ func (l *Library) drainQueue() {
|
||||
l.currentScanLibraryID = 0
|
||||
l.currentScanLibraryName = ""
|
||||
l.scanActive = false
|
||||
hooks := l.scanHooks
|
||||
l.mu.Unlock()
|
||||
|
||||
runtime.EventsEmit(l.ctx, events.LibraryScanQueueDrained)
|
||||
|
||||
if hooks.OnAllScansComplete != nil {
|
||||
hooks.OnAllScansComplete()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user