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:
2026-11-25 22:02:00 -05:00
co-authored by Claude Opus 5.5
parent 1ff4bc8258
commit 785b15ab5f
7 changed files with 123 additions and 10 deletions
+9
View File
@@ -38,6 +38,15 @@ UPDATE scan_runs
SET artist_art_enrich = $2
WHERE id = $1;
-- name: FailUnfinishedScanRuns :execrows
-- At startup no scan can be running yet, so a row still unfinished was cut
-- off when the server last stopped. Closing it keeps it from reading as a
-- scan in progress, which would block saving library folders.
UPDATE scan_runs
SET finished_at = now(),
error_message = 'The server stopped while the scan was running.'
WHERE finished_at IS NULL;
-- name: GetInFlightScanRun :one
-- Used by POST /api/admin/scan/run to 409 when a scan is already running.
-- "In flight" = finished_at IS NULL.