feat: Minstrel no longer talks to Lidarr: its connection, Delete via Lidarr and the unmonitor options are gone, and the track reports are plain quarantine (M502 #5525)
release / govulncheck (push) Successful in 15s
release / web (push) Failing after 17s
release / go (push) Successful in 1m13s
release / integration (push) Successful in 4m56s
release / android (push) Successful in 5m9s
release / Build signed APK (releases and dev) (push) Successful in 5m19s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

Migration 0091 drops lidarr_config and renames the quarantine tables, types,
indexes and the history column off the Lidarr name. The Integrations Lidarr
card, the Reports "Delete via Lidarr" action, the merge and remove-track
unmonitor options, the Lidarr audit actions and error codes go, on the
server, web and Android. The README describes acquisition as it is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 13:48:20 -04:00
co-authored by Claude Opus 5.5
parent c54792c51e
commit 3a16732883
170 changed files with 994 additions and 6242 deletions
+11 -207
View File
@@ -17,7 +17,7 @@ import (
"git.fabledsword.com/bvandeusen/minstrel/internal/dbtest"
)
// --- test seed helpers (inlined; mirrors lidarrquarantine patterns) -----
// --- test seed helpers (inlined; mirrors quarantine patterns) -----------
func newPool(t *testing.T) *pgxpool.Pool {
t.Helper()
@@ -95,23 +95,6 @@ func seedArtistAlbumTrack(t *testing.T, pool *pgxpool.Pool, prefix, mbid, filePa
return artist, album, track
}
// --- fake LidarrUnmonitorer --------------------------------------------
// fakeLidarrUnmonitorer captures call args + a configurable error so
// tests can assert "called with mbid X" and "RemoveTrack tolerated this
// Lidarr error."
type fakeLidarrUnmonitorer struct {
calls []string // captured trackMbid per call
albumMbid string // last albumMbid received
err error
}
func (f *fakeLidarrUnmonitorer) UnmonitorTrack(_ context.Context, trackMbid, albumMbid string) error {
f.calls = append(f.calls, trackMbid)
f.albumMbid = albumMbid
return f.err
}
// --- tests --------------------------------------------------------------
func TestRemoveTrack_NotFound(t *testing.T) {
@@ -122,8 +105,8 @@ func TestRemoveTrack_NotFound(t *testing.T) {
bogus.Bytes = [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
bogus.Valid = true
svc := NewService(pool, nil, nil, "")
_, _, _, err := svc.RemoveTrack(context.Background(), bogus, admin.ID, false)
svc := NewService(pool, nil, "")
_, _, err := svc.RemoveTrack(context.Background(), bogus, admin.ID)
if !errors.Is(err, ErrNotFound) {
t.Errorf("err = %v, want ErrNotFound", err)
}
@@ -138,18 +121,13 @@ func TestRemoveTrack_LocalFile_HappyPath(t *testing.T) {
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
// mbid empty → no Lidarr branch even with unmonitor=true.
_, _, track := seedArtistAlbumTrack(t, pool, "Solo", "", path)
fake := &fakeLidarrUnmonitorer{}
svc := NewService(pool, nil, fake, "")
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
svc := NewService(pool, nil, "")
_, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
if lidarrFailed {
t.Error("lidarrUnmonitorFailed = true; want false on local-file happy path")
}
if _, err := os.Stat(path); !errors.Is(err, os.ErrNotExist) {
t.Errorf("file still present: %v", err)
}
@@ -157,9 +135,6 @@ func TestRemoveTrack_LocalFile_HappyPath(t *testing.T) {
if _, err := q.GetTrackByID(context.Background(), track.ID); err == nil {
t.Errorf("track row still exists")
}
if len(fake.calls) != 0 {
t.Errorf("Lidarr called %d times; want 0 (no mbid, unmonitor=false)", len(fake.calls))
}
}
func TestRemoveTrack_FileAlreadyMissing(t *testing.T) {
@@ -170,8 +145,8 @@ func TestRemoveTrack_FileAlreadyMissing(t *testing.T) {
missing := filepath.Join(t.TempDir(), "does-not-exist.mp3")
_, _, track := seedArtistAlbumTrack(t, pool, "Ghost", "", missing)
svc := NewService(pool, nil, nil, "")
_, _, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
svc := NewService(pool, nil, "")
_, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
@@ -226,8 +201,8 @@ func TestRemoveTrack_Cascade_AlbumEmpty(t *testing.T) {
t.Fatalf("trackB: %v", err)
}
svc := NewService(pool, nil, nil, "")
delAlbum, delArtist, _, err := svc.RemoveTrack(context.Background(), trackA.ID, admin.ID, false)
svc := NewService(pool, nil, "")
delAlbum, delArtist, err := svc.RemoveTrack(context.Background(), trackA.ID, admin.ID)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
@@ -259,8 +234,8 @@ func TestRemoveTrack_Cascade_ArtistEmpty(t *testing.T) {
}
artist, album, track := seedArtistAlbumTrack(t, pool, "Lone", "", path)
svc := NewService(pool, nil, nil, "")
delAlbum, delArtist, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
svc := NewService(pool, nil, "")
delAlbum, delArtist, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
@@ -278,174 +253,3 @@ func TestRemoveTrack_Cascade_ArtistEmpty(t *testing.T) {
t.Errorf("artist still exists after cascade")
}
}
// unmonitor=true AND mbid set → Lidarr called once; lidarrUnmonitorFailed=false.
// Uses two albums on the same artist so the album's row survives the
// cascade — that lets us assert the album mbid (captured pre-tx) is
// passed through correctly.
func TestRemoveTrack_Unmonitor_HappyPath(t *testing.T) {
pool := newPool(t)
admin := seedAdmin(t, pool, "alice")
q := dbq.New(pool)
artist, err := q.UpsertArtist(context.Background(), dbq.UpsertArtistParams{
Name: "Lidarr Artist", SortName: "Lidarr Artist",
})
if err != nil {
t.Fatalf("artist: %v", err)
}
albumMbid := "album-mbid-xyz"
album, err := q.UpsertAlbum(context.Background(), dbq.UpsertAlbumParams{
Title: "Lidarr Album", SortTitle: "Lidarr Album",
ArtistID: artist.ID, Mbid: &albumMbid,
})
if err != nil {
t.Fatalf("album: %v", err)
}
dir := t.TempDir()
pathA := filepath.Join(dir, "a.mp3")
pathB := filepath.Join(dir, "b.mp3")
_ = os.WriteFile(pathA, []byte("x"), 0o644)
_ = os.WriteFile(pathB, []byte("x"), 0o644)
trackMbid := "track-mbid-abc"
track, err := q.UpsertTrack(context.Background(), dbq.UpsertTrackParams{
Title: "T1", AlbumID: album.ID, ArtistID: artist.ID,
DurationMs: 1000, FilePath: pathA, FileSize: 1, FileFormat: "mp3",
Mbid: &trackMbid,
})
if err != nil {
t.Fatalf("track1: %v", err)
}
// Sibling track keeps the album alive after the delete.
if _, err := q.UpsertTrack(context.Background(), dbq.UpsertTrackParams{
Title: "T2", AlbumID: album.ID, ArtistID: artist.ID,
DurationMs: 1000, FilePath: pathB, FileSize: 1, FileFormat: "mp3",
}); err != nil {
t.Fatalf("track2: %v", err)
}
fake := &fakeLidarrUnmonitorer{}
svc := NewService(pool, nil, fake, "")
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
if lidarrFailed {
t.Error("lidarrUnmonitorFailed = true; want false on happy path")
}
if len(fake.calls) != 1 {
t.Fatalf("Lidarr call count = %d, want 1", len(fake.calls))
}
if fake.calls[0] != trackMbid {
t.Errorf("Lidarr called with mbid %q, want %q", fake.calls[0], trackMbid)
}
if fake.albumMbid != albumMbid {
t.Errorf("Lidarr called with albumMbid %q, want %q", fake.albumMbid, albumMbid)
}
}
// unmonitor=true AND Lidarr fails → file + DB still deleted, flag set,
// service returns nil error.
func TestRemoveTrack_Unmonitor_LidarrErrorIsNonFatal(t *testing.T) {
pool := newPool(t)
admin := seedAdmin(t, pool, "alice")
q := dbq.New(pool)
artist, err := q.UpsertArtist(context.Background(), dbq.UpsertArtistParams{
Name: "ErrFatal Artist", SortName: "ErrFatal Artist",
})
if err != nil {
t.Fatalf("artist: %v", err)
}
albumMbid := "err-album-mbid"
album, err := q.UpsertAlbum(context.Background(), dbq.UpsertAlbumParams{
Title: "ErrFatal Album", SortTitle: "ErrFatal Album",
ArtistID: artist.ID, Mbid: &albumMbid,
})
if err != nil {
t.Fatalf("album: %v", err)
}
dir := t.TempDir()
path := filepath.Join(dir, "f.mp3")
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
trackMbid := "err-track-mbid"
track, err := q.UpsertTrack(context.Background(), dbq.UpsertTrackParams{
Title: "T", AlbumID: album.ID, ArtistID: artist.ID,
DurationMs: 1000, FilePath: path, FileSize: 1, FileFormat: "mp3",
Mbid: &trackMbid,
})
if err != nil {
t.Fatalf("track: %v", err)
}
fake := &fakeLidarrUnmonitorer{err: errors.New("simulated lidarr 5xx")}
svc := NewService(pool, nil, fake, "")
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
if err != nil {
t.Fatalf("RemoveTrack: %v (want nil — Lidarr failure is non-fatal)", err)
}
if !lidarrFailed {
t.Error("lidarrUnmonitorFailed = false; want true after Lidarr error")
}
// File + DB still gone.
if _, err := os.Stat(path); !errors.Is(err, os.ErrNotExist) {
t.Errorf("file still present after Lidarr error: %v", err)
}
if _, err := q.GetTrackByID(context.Background(), track.ID); err == nil {
t.Errorf("track row still present after Lidarr error")
}
}
// unmonitor=true AND mbid empty (non-Lidarr track) → no Lidarr call.
func TestRemoveTrack_Unmonitor_NoMbidSkipsLidarr(t *testing.T) {
pool := newPool(t)
admin := seedAdmin(t, pool, "alice")
dir := t.TempDir()
path := filepath.Join(dir, "local.mp3")
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
_, _, track := seedArtistAlbumTrack(t, pool, "Local", "", path)
fake := &fakeLidarrUnmonitorer{}
svc := NewService(pool, nil, fake, "")
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
if lidarrFailed {
t.Error("lidarrUnmonitorFailed = true; want false (no mbid)")
}
if len(fake.calls) != 0 {
t.Errorf("Lidarr call count = %d, want 0 (track has no mbid)", len(fake.calls))
}
}
// unmonitor=false AND mbid set → no Lidarr call.
func TestRemoveTrack_NoUnmonitor_SkipsLidarr(t *testing.T) {
pool := newPool(t)
admin := seedAdmin(t, pool, "alice")
dir := t.TempDir()
path := filepath.Join(dir, "lidarr.mp3")
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
_, _, track := seedArtistAlbumTrack(t, pool, "NoMon", "track-mbid", path)
fake := &fakeLidarrUnmonitorer{}
svc := NewService(pool, nil, fake, "")
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
if err != nil {
t.Fatalf("RemoveTrack: %v", err)
}
if lidarrFailed {
t.Error("lidarrUnmonitorFailed = true; want false (unmonitor=false)")
}
if len(fake.calls) != 0 {
t.Errorf("Lidarr call count = %d, want 0 (unmonitor=false)", len(fake.calls))
}
}