refactor(library): move detection matches on the audio hash, not size and duration (M400 #3914)
test-go / test (push) Successful in 1m9s
test-go / integration (push) Successful in 3m45s
release / Build signed APK (releases and dev) (push) Successful in 4m52s
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
test-go / test (push) Successful in 1m9s
test-go / integration (push) Successful in 3m45s
release / Build signed APK (releases and dev) (push) Successful in 4m52s
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
A file that comes back renamed or moved keeps its track row, and with it its likes and play history, by being matched to the missing row it replaces (#2528). Untagged files were matched on (file_size, duration_ms), which was never a fingerprint. It could pair two unrelated files that happened to share a byte count and a duration, and it missed a file retagged in place, whose size changes. The only defence was requiring a unique match and otherwise giving up. Now there is a real identity. FindMissingTrackByAudioHash matches a missing track by the SHA-256 of its encoded audio (track_fingerprints, #3906). That survives a rename, a move and a retag, and only an identical recording can match it. adoptMovedTrack takes the new file's hash, which the scan already computes before adoption. The size and duration query and fallback are removed outright, with no second path (rule 22). Unchanged: - MBID first: it identifies the recording and survives a re-encode that even the hash does not - a unique match is still required - an absent hash is never looked up, so unhashable files cannot pair with each other The test fake answers the hash lookup only for the hash it holds, so the tests can tell adoption by identity apart from adoption by coincidence. That includes the case the old pair got wrong: different audio of equal size and duration is not adopted. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SQ31KQpYbStyK5y58UmPLH
This commit is contained in:
@@ -211,9 +211,9 @@ func writeTestMP3(t *testing.T, path string, frames map[string]string) {
|
||||
// playlist memberships travel with it — rather than forking into a marked ghost
|
||||
// plus a fresh zero-history row.
|
||||
//
|
||||
// Uses the MBID path. The synthetic MP3s here carry no real audio, so ffprobe
|
||||
// yields duration 0 and the size+duration fingerprint is deliberately unusable —
|
||||
// which is why the recording MBID is the signal under test.
|
||||
// Uses the MBID path. The synthetic MP3s here carry no real audio, so their audio
|
||||
// stream hash cannot be relied on — which is why the recording MBID is the signal
|
||||
// under test. The audio-hash path is covered by moved_test.go.
|
||||
//
|
||||
// Eight tracks with one rename keeps the marked fraction at 12.5%, under
|
||||
// missingMarkMaxFraction. That is load-bearing: if the rename exceeded the cap,
|
||||
|
||||
Reference in New Issue
Block a user