Par2 merge: a set file matching several releases nearby is ambiguous
Test and deploy / test (push) Successful in 1m1s
Test and deploy / edge (push) Successful in 2m15s
Test and deploy / deploy (push) Successful in 2m4s

131 uploads of 1 GiB test files ("kantodoNNN.bin", a.b.test) share their
first 16 KiB and size, so all matched one set's single file and became one
release of 1,284 files. A par2 file that matches more than one release in
the anchor's group and time window is left out; a plain repost of the same
file stays apart too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-12 10:15:32 +02:00
1 parent 8e07478659
commit 6d1f2cc2a1
2 files changed
+49 -12

No files matched your search

+21
View File
@@ -62,4 +62,25 @@ test.group('Par2Merger', (group) => {
// Again: nothing new.
assert.deepEqual(await new Par2Merger().round().then((r) => r.merges), 0)
})
test('a set file that matches several releases nearby is ambiguous: not merged', async ({ assert }) => {
const at = new Date('2022-07-08T03:46:00Z')
const ids: number[] = []
for (const key of ['aa000001', 'aa000002', 'aa000003']) {
const [row] = await db
.table('releases')
.insert({ release_key: key.padEnd(40, '0'), identity_key: key.padEnd(40, '0'), name: key, source: 'stem', groups: '[]', group_id: 1, files: 1, posted_at: at, readable: false })
.returning('id')
ids.push(Number(row.id))
}
// Two test uploads whose 1 GiB files start alike, and a set describing one such file, held by the third.
await db.table('file_hashes').multiInsert([
{ candidate_id: 2001, release_id: ids[0], hash16k: hash('f'), size: 1073741824 },
{ candidate_id: 2002, release_id: ids[1], hash16k: hash('f'), size: 1073741824 },
])
await db.table('par2_files').insert({ set_id: hash('9'), file_id: hash('8'), hash16k: hash('f'), length: 1073741824, name: 'kantibanito1.bin' })
await db.table('par2_sets').insert({ set_id: hash('9'), release_id: ids[2], files: 1 })
assert.equal((await new Par2Merger().round()).merges, 0)
assert.equal((await db.from('releases').whereIn('id', ids).select('id')).length, 3)
})
})