Prober: a flush with a NUL in a name, or one article twice, no longer fails
jsonb can't hold \u0000, and ON CONFLICT can't take a row twice in one statement: either failed the whole flush, its outcomes lost and its candidates taken until a restart. NULs are dropped from strings; the probe_cache insert takes each message-id once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9fb36d217c
commit
d405b658c3
2 files changed
+37
-7
No files matched your search
@@ -23,4 +23,23 @@ test.group('Prober', (group) => {
|
||||
const status = Object.fromEntries((await db.from('probe_candidates').select('kind', 'status')).map((c) => [c.kind, c.status]))
|
||||
assert.deepEqual(status, { 'lone': 'taken', 'par2': 'taken', 'archive': 'taken', '7z-tail': 'waiting' })
|
||||
})
|
||||
|
||||
test('a flush stores a name with a NUL in it, and one article that two releases have as a candidate', async ({ assert }) => {
|
||||
const release = async (key: string) =>
|
||||
Number((await db.table('releases').insert({ release_key: key.padEnd(40, '0'), identity_key: key.padEnd(40, '0'), name: key, source: 'subject', groups: '[]', files: 1 }).returning('id'))[0].id)
|
||||
const a = await release('fa')
|
||||
const b = await release('fb')
|
||||
const candidate = async (releaseId: number) =>
|
||||
Number((await db.table('probe_candidates').insert({ release_id: releaseId, kind: 'archive', message_id: '<same@x>', file: 'x.rar', status: 'taken' }).returning('id'))[0].id)
|
||||
const inspection = { yencName: 'x.rar', size: 1000, type: null, names: ['Movie\u0000.mkv'], entries: 1, passworded: false }
|
||||
const prober = new Prober() as any
|
||||
for (const releaseId of [a, b]) {
|
||||
prober.outcomes.push({ candidate: { id: await candidate(releaseId), releaseId, kind: 'archive', messageId: '<same@x>' }, status: 'done', inspection })
|
||||
}
|
||||
await prober.flush()
|
||||
assert.deepEqual((await db.from('probe_candidates').select('status')).map((c) => c.status), ['done', 'done'])
|
||||
const cached = await db.from('probe_cache').where('message_id', '<same@x>').firstOrFail()
|
||||
assert.deepEqual(cached.result.names, ['Movie.mkv'])
|
||||
assert.equal((await db.from('release_inspections').count('* as n'))[0].n, '2')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user