main: fold the two infohash-dedup paths into one

dedupeTorrents and markInfoHash were the same map-of-infohash logic, one
batch and one incremental, with the same hazard explained in prose four
times. Both now go through a single seenInfoHash helper.
This commit is contained in:
2026-06-22 08:27:34 +09:00
parent a40cc67c38
commit b98c36acb7
3 changed files with 28 additions and 40 deletions

View File

@@ -241,13 +241,13 @@ func TestFollowUpInfoHashDedup(t *testing.T) {
}
seen := map[metainfo.Hash]string{}
if first, dup := markInfoHash(seen, a); dup {
if first, dup := seenInfoHash(seen, a, true); dup {
t.Fatalf("a is the first occurrence, wrongly flagged a duplicate of %s", first)
}
if first, dup := markInfoHash(seen, b); !dup || first != a {
if first, dup := seenInfoHash(seen, b, true); !dup || first != a {
t.Errorf("b should duplicate a: got first=%q dup=%v, want %q true", first, dup, a)
}
if _, dup := markInfoHash(seen, c); dup {
if _, dup := seenInfoHash(seen, c, true); dup {
t.Errorf("c is a distinct torrent, wrongly flagged a duplicate")
}
}