From e6e3f297d64b2cc33ee0b5b1c8dcb3072c3e8524 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 30 Apr 2026 17:32:08 -0400 Subject: [PATCH] fix(dbtest,library): include quarantine tables in ResetDB; clarify DeleteTrackFile docstring - dbtest.ResetDB.dataTables now truncates lidarr_quarantine + lidarr_quarantine_actions alongside the other M2-M4 data tables. Without this, M5b service tests would inherit residual state across runs. - DeleteTrackFile godoc spells out the post-file/pre-DB failure window reconciles via the next library scan; the function is retry-safe by design, not atomic. --- internal/dbtest/reset.go | 2 ++ internal/library/delete.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/dbtest/reset.go b/internal/dbtest/reset.go index 4f821232..65c72225 100644 --- a/internal/dbtest/reset.go +++ b/internal/dbtest/reset.go @@ -49,6 +49,8 @@ var dataTables = []string{ "skip_events", "play_sessions", "sessions", + "lidarr_quarantine_actions", + "lidarr_quarantine", "tracks", "albums", "artists", diff --git a/internal/library/delete.go b/internal/library/delete.go index 133f6496..9f701a0d 100644 --- a/internal/library/delete.go +++ b/internal/library/delete.go @@ -27,7 +27,10 @@ var ErrTrackNotFound = errors.New("library: track not found") // 3. Delete the tracks row. // // Order matters: file first, then DB. If the file delete fails (permission, -// I/O error), we leave the DB row alone so the admin can retry. +// I/O error), we leave the DB row alone so the admin can retry. The reverse +// failure mode — file gone, DB row still present — is recoverable: the next +// library scan reconciles missing files by removing their tracks rows. So +// the function is retry-safe rather than atomic, by design. func DeleteTrackFile(ctx context.Context, pool *pgxpool.Pool, trackID pgtype.UUID) error { q := dbq.New(pool) track, err := q.GetTrackByID(ctx, trackID)