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:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user