Par2 merge: a set held by two merged releases; one failed set doesn't stop a round
A par2 index and its repost both hold a set: moving both rows to the target broke par2_sets' primary key, and the round failed on it every minute from 20:28 UTC (no merges at all). Duplicates among the others go first; a set that fails is logged and the round goes on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b99cfdb0e
commit
c72bf68fd2
2 files changed
+36
-3
No files matched your search
@@ -63,6 +63,29 @@ test.group('Par2Merger', (group) => {
|
||||
assert.deepEqual(await new Par2Merger().round().then((r) => r.merges), 0)
|
||||
})
|
||||
|
||||
test('a set held by two of the releases merged is held once by the target', async ({ assert }) => {
|
||||
const at = new Date('2022-07-08T03:46:00Z')
|
||||
const ids: number[] = []
|
||||
for (const [key, files] of [['bb000001', 1], ['bb000002', 1], ['bb000003', 3]] as const) {
|
||||
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, posted_at: at, readable: false })
|
||||
.returning('id')
|
||||
ids.push(Number(row.id))
|
||||
}
|
||||
const setId = hash('7')
|
||||
// The par2 index and its repost each hold the set; the third release holds the data file.
|
||||
await db.table('par2_sets').multiInsert([
|
||||
{ set_id: setId, release_id: ids[0], files: 1 },
|
||||
{ set_id: setId, release_id: ids[1], files: 1 },
|
||||
])
|
||||
await db.table('par2_files').insert({ set_id: setId, file_id: hash('6'), hash16k: hash('5'), length: 1000, name: 'x.rar' })
|
||||
await db.table('file_hashes').insert({ candidate_id: 3001, release_id: ids[2], hash16k: hash('5'), size: 1000 })
|
||||
assert.equal(await new Par2Merger().mergeSet(setId), 2)
|
||||
const held = await db.from('par2_sets').where('set_id', setId).select('release_id')
|
||||
assert.deepEqual(held.map((r) => Number(r.release_id)), [ids[2]])
|
||||
})
|
||||
|
||||
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[] = []
|
||||
|
||||
Reference in new issue
Block a user