feat: when no slot an album gives one recording is its own, every copy is removed and the album fetched again (M498)
release / govulncheck (push) Successful in 14s
release / web (push) Successful in 1m28s
release / go (push) Failing after 1m31s
release / integration (push) Successful in 5m15s
release / android (push) Successful in 5m23s
release / Build signed APK (releases and dev) (push) Successful in 5m37s
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 14s
release / web (push) Successful in 1m28s
release / go (push) Failing after 1m31s
release / integration (push) Successful in 5m15s
release / android (push) Successful in 5m23s
release / Build signed APK (releases and dev) (push) Successful in 5m37s
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
Shnabubula's whole album, one 45-minute file, was filed as both Fading Light and Looking for Answers. Neither slot fits, so wrongSlots had nothing to keep and held the group. Every copy now goes when each is clearly another song's; a copy near its slot still holds the group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
// long as the file and every other slot's song is clearly not, the copies
|
||||
// in the other slots are removed and their tracks marked missing, so the
|
||||
// reacquisition sweeper wants the album back and a good copy fills them.
|
||||
// When every slot's song is clearly not the file, every copy goes.
|
||||
// Anything less certain stays with the operator.
|
||||
|
||||
const (
|
||||
@@ -52,8 +53,11 @@ type slotCopy struct {
|
||||
}
|
||||
|
||||
// wrongSlots decides which copies of a one-album mismatch sit in a slot that
|
||||
// is not theirs. keep is the copy whose slot fits the recording; ok is false
|
||||
// when the track list cannot say, and nothing should be removed.
|
||||
// is not theirs. keep is the copy whose slot fits the recording, or -1 when
|
||||
// every copy is clearly another song's (Shnabubula's whole album, 45 minutes
|
||||
// in one file, filed as both "Fading Light" and "Looking for Answers"): then
|
||||
// all of them go. ok is false when the track list cannot say, and nothing
|
||||
// should be removed.
|
||||
//
|
||||
// Several copies may fit when they carry the same title ("Killjoy" twice
|
||||
// beside "Dreamland"): they are one song held twice, not a wrong slot, so they
|
||||
@@ -92,7 +96,9 @@ func wrongSlots(copies []slotCopy, tracks []dbq.MbReleaseTrack) (keep int, loser
|
||||
return -1, nil, false
|
||||
}
|
||||
}
|
||||
if keep < 0 || len(losers) == 0 {
|
||||
// A copy that neither fits nor is clearly another song's has returned
|
||||
// above, so with no keep every copy is a loser.
|
||||
if len(losers) == 0 {
|
||||
return -1, nil, false
|
||||
}
|
||||
return keep, losers, true
|
||||
@@ -261,17 +267,21 @@ func removeWrongSlots(
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
kept := g.members[keep]
|
||||
audit.WriteOrLog(ctx, pool, logger, pgtype.UUID{}, pgtype.UUID{}, audit.ActionDuplicateWrongFile, map[string]any{
|
||||
"automatic": true,
|
||||
"group_id": syncpkg.FormatUUID(g.id),
|
||||
"artist": kept.ArtistName,
|
||||
"kept_title": kept.Title,
|
||||
"kept_path": kept.FilePath,
|
||||
"removed": removedFiles,
|
||||
})
|
||||
details := map[string]any{
|
||||
"automatic": true,
|
||||
"group_id": syncpkg.FormatUUID(g.id),
|
||||
"artist": g.members[0].ArtistName,
|
||||
"removed": removedFiles,
|
||||
}
|
||||
keptPath := ""
|
||||
if keep >= 0 {
|
||||
kept := g.members[keep]
|
||||
details["kept_title"], details["kept_path"] = kept.Title, kept.FilePath
|
||||
keptPath = kept.FilePath
|
||||
}
|
||||
audit.WriteOrLog(ctx, pool, logger, pgtype.UUID{}, pgtype.UUID{}, audit.ActionDuplicateWrongFile, details)
|
||||
logger.Info("duplicate resolve: removed copies from slots that were not theirs",
|
||||
"group_id", syncpkg.FormatUUID(g.id), "kept", kept.FilePath, "removed", len(gone))
|
||||
"group_id", syncpkg.FormatUUID(g.id), "kept", keptPath, "removed", len(gone))
|
||||
return len(gone), removeErr
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user