feat(ui): add scan progress and error reporting to UI (#4094)
* feat(scanner): add LastScanError tracking to scanner status - Introduced LastScanErrorKey constant for error tracking. - Updated StatusInfo struct to include LastError field. - Modified scanner logic to store and retrieve last scan error. - Enhanced ScanStatus response to include error information. - Updated UI components to display last scan error when applicable. - Added tests to verify last scan error functionality. Signed-off-by: Deluan <deluan@navidrome.org> * feat(scanner): enhance scan status with type and elapsed time tracking - Added LastScanTypeKey and LastScanStartTimeKey constants for tracking scan type and start time. - Updated StatusInfo struct to include ScanType and ElapsedTime fields. - Implemented getScanInfo method to retrieve scan type, elapsed time, and last error. - Modified scanner logic to store scan type and start time during scans. - Enhanced ScanStatus response and UI components to display scan type and elapsed time. - Added formatShortDuration utility for better elapsed time representation. - Updated activity reducer to handle new scan status fields. Signed-off-by: Deluan <deluan@navidrome.org> * refactor(tests): consolidate controller status tests into a single file - Removed the old controller_status_test.go file. - Merged relevant tests into the new controller_test.go file for better organization and maintainability. - Ensured all existing test cases for controller status are preserved and functional. Signed-off-by: Deluan <deluan@navidrome.org> * Fix formatting issues * refactor(scanner): update getScanInfo method documentation --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -57,12 +57,21 @@ func (s *scannerImpl) scanAll(ctx context.Context, fullScan bool, progress chan<
|
||||
startTime := time.Now()
|
||||
log.Info(ctx, "Scanner: Starting scan", "fullScan", state.fullScan, "numLibraries", len(libs))
|
||||
|
||||
// Store scan type and start time
|
||||
scanType := "quick"
|
||||
if state.fullScan {
|
||||
scanType = "full"
|
||||
}
|
||||
_ = s.ds.Property(ctx).Put(consts.LastScanTypeKey, scanType)
|
||||
_ = s.ds.Property(ctx).Put(consts.LastScanStartTimeKey, startTime.Format(time.RFC3339))
|
||||
|
||||
// if there was a full scan in progress, force a full scan
|
||||
if !state.fullScan {
|
||||
for _, lib := range libs {
|
||||
if lib.FullScanInProgress {
|
||||
log.Info(ctx, "Scanner: Interrupted full scan detected", "lib", lib.Name)
|
||||
state.fullScan = true
|
||||
_ = s.ds.Property(ctx).Put(consts.LastScanTypeKey, "full")
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -100,11 +109,14 @@ func (s *scannerImpl) scanAll(ctx context.Context, fullScan bool, progress chan<
|
||||
)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Scanner: Finished with error", "duration", time.Since(startTime), err)
|
||||
_ = s.ds.Property(ctx).Put(consts.LastScanErrorKey, err.Error())
|
||||
state.sendError(err)
|
||||
s.metrics.WriteAfterScanMetrics(ctx, false)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.ds.Property(ctx).Put(consts.LastScanErrorKey, "")
|
||||
|
||||
if state.changesDetected.Load() {
|
||||
state.sendProgress(&ProgressInfo{ChangesDetected: true})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user