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
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:
@@ -238,7 +238,8 @@ func settleWrongSlots(
|
||||
// Set aside before the files go: a pass that dies between the two
|
||||
// still does not fetch the same files again.
|
||||
blocked := blockReleasesHolding(ctx, pool, logger, g)
|
||||
n, err := removeWrongSlots(ctx, pool, logger, g, keep, losers, blocked)
|
||||
emptied := emptiedSlots(ctx, q, logger, g, losers, tracks)
|
||||
n, err := removeWrongSlots(ctx, pool, logger, g, keep, losers, emptied, blocked)
|
||||
removed += n
|
||||
if err != nil {
|
||||
logger.Warn("duplicate resolve: removing wrong-slot copies failed", "group_id", syncpkg.FormatUUID(g.id), "err", err)
|
||||
@@ -385,6 +386,46 @@ func blockReleasesHolding(ctx context.Context, pool *pgxpool.Pool, logger *slog.
|
||||
return names
|
||||
}
|
||||
|
||||
// emptiedSlots is the losers whose song the album holds no other copy of:
|
||||
// no present track on it under that title as long as the song's slot. Those
|
||||
// wait for a copy fetched again (migration 0095). The rest are the song held
|
||||
// twice, and missing-pair folding folds them into the copy held: Savant's
|
||||
// VOID DLC "Weeper" beside Void's. A failed read counts every loser as
|
||||
// emptied, which only makes the album wait for a copy it may not need.
|
||||
func emptiedSlots(
|
||||
ctx context.Context, q *dbq.Queries, logger *slog.Logger, g *resolveGroup, losers []int, tracks []dbq.MbReleaseTrack,
|
||||
) []pgtype.UUID {
|
||||
held, err := q.ListTracksByAlbum(ctx, dbq.ListTracksByAlbumParams{AlbumID: g.members[0].AlbumID})
|
||||
if err != nil {
|
||||
logger.Warn("duplicate resolve: reading the album's tracks failed", "group_id", syncpkg.FormatUUID(g.id), "err", err)
|
||||
}
|
||||
inGroup := map[pgtype.UUID]bool{}
|
||||
for _, m := range g.members {
|
||||
inGroup[m.TrackID] = true
|
||||
}
|
||||
var emptied []pgtype.UUID
|
||||
for _, i := range losers {
|
||||
m := g.members[i]
|
||||
key := MatchTitleKey(m.Title, m.ArtistName)
|
||||
covered := false
|
||||
for _, h := range held {
|
||||
if covered || h.MissingSince.Valid || inGroup[h.ID] || MatchTitleKey(h.Title, m.ArtistName) != key {
|
||||
continue
|
||||
}
|
||||
for _, t := range tracks {
|
||||
if t.LengthMs > 0 && MatchTitleKey(t.Title, m.ArtistName) == key && absMs(t.LengthMs-h.DurationMs) <= slotFit {
|
||||
covered = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !covered {
|
||||
emptied = append(emptied, m.TrackID)
|
||||
}
|
||||
}
|
||||
return emptied
|
||||
}
|
||||
|
||||
// neverRead reports whether the catalogue has never read a release group's
|
||||
// releases. A group read and found empty is not asked about again: the
|
||||
// catalogue's own refresh revisits it.
|
||||
@@ -397,12 +438,14 @@ func neverRead(ctx context.Context, q *dbq.Queries, rg string) bool {
|
||||
// the same transaction that closes the group. The row is kept, with its likes
|
||||
// and plays: it is the slot, and a good copy fetched again takes it over. Its
|
||||
// recording MBID is dropped, being the wrong file's, so missing-pair folding
|
||||
// does not fold the slot into the copy that was kept. blocked names the
|
||||
// releases set aside, for the record. A file that cannot be removed stops the
|
||||
// group; the ones already gone are still marked, and the group waits for the
|
||||
// next pass.
|
||||
// does not fold the slot into the copy that was kept. The slots in emptied
|
||||
// are stamped to wait for a copy fetched again (emptiedSlots). blocked names
|
||||
// the releases set aside, for the record. A file that cannot be removed stops
|
||||
// the group; the ones already gone are still marked, and the group waits for
|
||||
// the next pass.
|
||||
func removeWrongSlots(
|
||||
ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger, g *resolveGroup, keep int, losers []int, blocked []string,
|
||||
ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger, g *resolveGroup, keep int, losers []int,
|
||||
emptied []pgtype.UUID, blocked []string,
|
||||
) (int, error) {
|
||||
var gone []pgtype.UUID
|
||||
var removedFiles []map[string]string
|
||||
@@ -429,6 +472,9 @@ func removeWrongSlots(
|
||||
if err := tq.ClearTrackMbids(ctx, gone); err != nil {
|
||||
return fmt.Errorf("clear mbids: %w", err)
|
||||
}
|
||||
if err := tq.MarkTracksEmptied(ctx, emptied); err != nil {
|
||||
return fmt.Errorf("mark emptied: %w", err)
|
||||
}
|
||||
if err := logTrackChanges(ctx, tq, gone); err != nil {
|
||||
return fmt.Errorf("log changes: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user