fix(library): a scan cut off by a restart no longer blocks saving library folders
A restart mid-scan left its scan_runs row unfinished, and saving library
folders refused ("A library scan is running") until a later scan reaped it,
up to 12 hours on. Startup now closes such rows with the reason before the
boot scan, as backups already do. Saving folders and the duplicate sweep
share one check that treats a run past StuckScanThreshold as dead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,13 +80,13 @@ func (s *Scanner) SetRoots(ctx context.Context, changes []RootChange) (RerootRes
|
||||
q := dbq.New(s.pool)
|
||||
// A scan walking the old folders would put their paths back, or mark the
|
||||
// moved rows missing when it reconciles.
|
||||
_, err = q.GetInFlightScanRun(ctx)
|
||||
if err == nil {
|
||||
return RerootResult{}, badRoots("A library scan is running; save again once it finishes.")
|
||||
}
|
||||
if !errors.Is(err, pgx.ErrNoRows) {
|
||||
running, err := scanRunning(ctx, q)
|
||||
if err != nil {
|
||||
return RerootResult{}, fmt.Errorf("in-flight scan check: %w", err)
|
||||
}
|
||||
if running {
|
||||
return RerootResult{}, badRoots("A library scan is running; save again once it finishes.")
|
||||
}
|
||||
for _, m := range moves {
|
||||
if err := checkMove(ctx, q, m); err != nil {
|
||||
return RerootResult{}, err
|
||||
|
||||
Reference in New Issue
Block a user