feat(library): removing a bad file keeps its track, waiting for a good copy
release / go (push) Successful in 2m6s
release / web (push) Successful in 1m15s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m46s
release / android (push) Successful in 4m47s
release / Build signed APK (push) Successful in 5m38s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 31s
release / Verify release artifacts (tag releases only) (push) Skipped

Reports, Duplicates and Suspect sources now end the same way: the file
goes and the track stays, marked missing with its likes, plays and
playlist places, until a good copy lands in the library and move
adoption or missing-pair folding brings it back.

- library.RemoveFile removes one track's file and marks the track
  missing with the queue it was removed from and who removed it
  (tracks.removed_reason / removed_by, migration 0104). The duplicate
  resolver's wrong-slot removal shares the same marking.
- POST /api/admin/quarantine/{id}/remove-file removes a reported file,
  clears the listeners' reports, marks open playback errors deleted and
  records removed_file in the Reports history. A wrong-file or
  wrong-tags report drops the file's recording MBID.
- POST /api/admin/library/suspect-sources/{id}/remove removes a video
  rip's file and its MBID, and writes a suspect_file_remove audit row.
- The removal reason clears with the missing mark when a file returns.

Grimoire #7743 (milestone 635).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 18:17:26 -05:00
co-authored by Claude Opus 5.5
parent e5f11647ee
commit 9462052625
21 changed files with 694 additions and 28 deletions
+19 -2
View File
@@ -188,9 +188,12 @@ SELECT t.id, t.file_path
--
-- `missing_since IS NOT NULL` again, this time as a race guard: two files can't
-- both adopt the same row, and :execrows reports 0 to whichever loses.
-- A removal's reason goes with the mark: the track has its file again.
UPDATE tracks
SET file_path = sqlc.arg(file_path),
missing_since = NULL
missing_since = NULL,
removed_reason = NULL,
removed_by = NULL
WHERE id = sqlc.arg(id)
AND missing_since IS NOT NULL;
@@ -216,6 +219,18 @@ UPDATE tracks
WHERE id = ANY(sqlc.arg(ids)::uuid[])
AND missing_since IS NULL;
-- name: MarkTracksRemoved :execrows
-- Marks rows whose file an admin, or the duplicate resolver, removed on
-- purpose: missing, like a file the walk did not see, with the queue it was
-- removed from and who removed it (NULL for the resolver). The row keeps its
-- likes, plays and playlist places, and a good copy that lands later is
-- adopted or folded into it. A row already missing keeps the time it went.
UPDATE tracks
SET missing_since = COALESCE(missing_since, now()),
removed_reason = sqlc.arg(reason)::text,
removed_by = sqlc.narg(removed_by)::uuid
WHERE id = ANY(sqlc.arg(ids)::uuid[]);
-- name: ClearTrackMbids :exec
-- Forgets the recording MBID of rows whose file was another song's (the
-- duplicate resolver's wrong-slot removal). The MBID came from that file, so it
@@ -240,7 +255,9 @@ UPDATE tracks
-- skip check, so a file that reappears unchanged is un-marked even though the
-- scanner skips re-reading its tags.
UPDATE tracks
SET missing_since = NULL
SET missing_since = NULL,
removed_reason = NULL,
removed_by = NULL
WHERE id = ANY(sqlc.arg(ids)::uuid[])
AND missing_since IS NOT NULL;