fix: a slot the resolver emptied folds only into a copy of its own song (M498)
release / govulncheck (push) Successful in 16s
release / web (push) Successful in 1m28s
release / go (push) Successful in 1m36s
release / android (push) Successful in 5m2s
release / integration (push) Failing after 5m7s
release / Build signed APK (releases and dev) (push) Successful in 5m12s
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

On 2026-10-20 the emptied "Open the Gateway" slot of Auvic's Speed Demons
was folded by title into another file tagged "Open the Gateway" that holds
Onward (244 s against the song's 254 s), so the album was never wanted
back. A wrong-slot removal now stamps tracks.emptied_at (migration 0095)
when the album holds no copy of the song as long as its MusicBrainz slot,
and missing-pair folding pairs such a row by title only with a track added
since: a copy fetched again. A slot whose song the album does hold (VOID
DLC's Weeper beside Void's) folds into it as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 11:55:23 -04:00
co-authored by Claude Opus 5.5
parent 09e74a57a2
commit 3ebd35e51d
13 changed files with 179 additions and 21 deletions
@@ -417,6 +417,54 @@ func TestResolveDuplicates_RemovesACopyFromAnotherSongsSlot_Integration(t *testi
}
}
// A slot emptied of another song's file folds into a copy of its own song the
// album already holds (Savant's VOID DLC "Weeper" beside Void's). A copy under
// the title that is not as long as the song is another song (the emptied "Open
// the Gateway" folded into a file holding Onward, 2026-10-20): the slot waits
// for a copy fetched again, and folds into that.
func TestResolveDuplicates_EmptiedSlotFoldsOnlyIntoItsOwnSong_Integration(t *testing.T) {
for _, tc := range []struct {
name string
heldMs int32
foldsFirst int
}{
{"the album holds Reach", 281500, 1},
{"the album holds a file titled Reach that is not", 220000, 0},
} {
t.Run(tc.name, func(t *testing.T) {
f := newOneAlbumFixture(t, "acoustic", "Void", "Reach")
ctx := context.Background()
q := dbq.New(f.pool)
seedTrackList(t, f.pool, f.album, map[string]int{"Void": 220500, "Reach": 281000})
held := func(name string, ms int32) {
t.Helper()
if _, err := q.UpsertTrack(ctx, dbq.UpsertTrackParams{
Title: "Reach", AlbumID: f.album.ID, ArtistID: f.a.ArtistID,
DurationMs: ms, FilePath: filepath.Join(filepath.Dir(f.aPath), name), FileSize: 100, FileFormat: "m4a",
}); err != nil {
t.Fatal(err)
}
}
held("17 - Reach (other edition).m4a", tc.heldMs)
res, err := ResolveDuplicates(ctx, f.pool, nil, "", true)
if err != nil || res.WrongFiles != 1 {
t.Fatalf("resolve = %+v, %v; want Reach's slot emptied", res, err)
}
pairs, err := PairMissingTracks(ctx, f.pool, nil)
if err != nil || pairs.Folded() != tc.foldsFirst {
t.Fatalf("missing-pair pass = %+v, %v; want %d folded", pairs, err, tc.foldsFirst)
}
if tc.foldsFirst == 1 {
return
}
held("17 - Reach (fetched again).m4a", 281200)
if pairs, err := PairMissingTracks(ctx, f.pool, nil); err != nil || pairs.Folded() != 1 {
t.Fatalf("missing-pair pass after the fetch = %+v, %v; want the slot folded into the copy fetched", pairs, err)
}
})
}
}
// One recording filling two slots whose songs are both clearly something else
// (Shnabubula's whole album in one file): both copies go, nothing is kept.
func TestResolveDuplicates_RemovesEveryCopyWhenNoSlotIsTheirs_Integration(t *testing.T) {