feat(11-01): per-library scan pipeline with queue coordinator
Task 1: Schema, events, and progress types - Add library_id to CreateAudioFile SQL INSERT and regenerate sqlc code - Add LibraryScanQueued and LibraryScanQueueDrained event constants - Regenerate TypeScript events via genevents - Add LibraryID, LibraryName, QueuedCount to ScanProgress - Add LibraryID, LibraryName to ScanMetrics - Add libraryID field to importResult for threading through pipeline Task 2: Scan queue coordinator and per-library scanning - Create scan_queue.go with ScanLibrary(id), ScanAllLibraries() - Add CancelCurrentScan(), CancelAllScans() for queue-aware cancellation - FIFO scan queue with silent dedup (same library already scanning or queued) - Refactor Scan() -> scanInternal(libraryID, libraryName, libraryPath) - Replace GetAllAudioFiles with GetAudioFilesByLibrary for per-library loading - Thread libraryID through DB writer to set CreateAudioFileParams.LibraryID - drainQueue auto-starts next queued library or emits LibraryScanQueueDrained - Pause freezes current scan AND queue - Add GetScanQueueLength() and QueuedLibraryNames() for UI - Mark CancelScan() and Scan() as deprecated
This commit is contained in:
@@ -53,6 +53,10 @@ type ScanMetrics struct {
|
||||
// Cancelled is true when the scan was stopped via CancelScan.
|
||||
Cancelled bool `json:"cancelled"`
|
||||
|
||||
// Library identification.
|
||||
LibraryID int64 `json:"libraryId"` // library that was scanned
|
||||
LibraryName string `json:"libraryName"` // display name of scanned library
|
||||
|
||||
// Non-fatal issues encountered during scanning.
|
||||
Warnings []ScanWarning `json:"warnings"`
|
||||
}
|
||||
@@ -60,12 +64,15 @@ type ScanMetrics struct {
|
||||
// ScanProgress is the payload emitted periodically during a scan to
|
||||
// report live progress to the frontend.
|
||||
type ScanProgress struct {
|
||||
Phase string `json:"phase"` // "counting", "scanning", "orphans", "thumbnails"
|
||||
Total int64 `json:"total"` // total audio files from pre-walk count
|
||||
Processed int64 `json:"processed"` // added + skipped + updated so far
|
||||
Added int64 `json:"added"`
|
||||
Skipped int64 `json:"skipped"`
|
||||
Updated int64 `json:"updated"`
|
||||
Phase string `json:"phase"` // "counting", "scanning", "orphans", "thumbnails"
|
||||
Total int64 `json:"total"` // total audio files from pre-walk count
|
||||
Processed int64 `json:"processed"` // added + skipped + updated so far
|
||||
Added int64 `json:"added"`
|
||||
Skipped int64 `json:"skipped"`
|
||||
Updated int64 `json:"updated"`
|
||||
LibraryID int64 `json:"libraryId"` // library being scanned
|
||||
LibraryName string `json:"libraryName"` // display name of library being scanned
|
||||
QueuedCount int `json:"queuedCount"` // number of libraries still queued after this one
|
||||
}
|
||||
|
||||
// ScanWarning represents a non-fatal issue encountered during scanning.
|
||||
|
||||
Reference in New Issue
Block a user