Each release chunk is a release inserted once: release_key the SHA-1 of the identity, the owner group and the first article (deterministic; no numbering under a group lock), identity_key the identity's SHA-1 bytes, poster_id and group_set_id through catalog_refs (cached per process), source as a code (weak-stem added), the name into release_texts. A finished release's candidates are claimable at once; a provisional tail release is finished by a later chunk of its key, a finished one sent again is left alone. Gone: joins into earlier releases and across groups, key numbering, the group lock, the fragment merger. Interim: chunks, counts and samples keyed by ranges.block_id, a range without a block gets one. Readers follow: search (posters and group_sets joined, words through release_texts, posters by id, source by code), the par2 merger, the sidecar folder, the judge's scraped rule, the spot inspector, the spotter, the NZB service, releases:regroup, edge:bench. Tests insert fixtures through tests/functional/helpers/releases.ts; the suites pass again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
import { test } from '@japa/runner'
|
|
import db from '@adonisjs/lucid/services/db'
|
|
import testUtils from '@adonisjs/core/services/test_utils'
|
|
import { pruneSevenZipTails } from '#services/seven_zip_tails'
|
|
import { insertReleases } from '#tests/functional/helpers/releases'
|
|
|
|
test.group('7z tails', (group) => {
|
|
group.each.setup(() => testUtils.db().withGlobalTransaction())
|
|
|
|
test("of a release's waiting tails, those below its highest volume go; the highest volume's all stay", async ({ assert }) => {
|
|
const row = (key: string) => ({ release_key: key.padEnd(40, '0'), identity_key: key.padEnd(40, '0'), name: key, source: 'stem', groups: '[]', files: 4 })
|
|
const [merged, other] = await insertReleases([row('a'), row('b')])
|
|
const tail = (releaseId: number, volume: string, mid: string, status = 'waiting') => ({ release_id: releaseId, kind: '7z-tail', message_id: mid, file: `x.7z.${volume}`, status })
|
|
await db.table('probe_candidates').multiInsert([
|
|
// Two merged members' tails, one of the highest volume probed already.
|
|
tail(merged, '002', '<1@x>'),
|
|
tail(merged, '005', '<2@x>'),
|
|
tail(merged, '003', '<3@x>', 'done'),
|
|
tail(merged, '009', '<4@x>', 'taken'),
|
|
// Two pieces that each saw part of volume 009.
|
|
tail(merged, '009', '<5@x>'),
|
|
{ release_id: merged, kind: 'archive', message_id: '<6@x>', file: 'x.7z.001' },
|
|
// Another release: not asked for.
|
|
tail(other, '002', '<7@x>'),
|
|
tail(other, '004', '<8@x>'),
|
|
])
|
|
assert.equal(await pruneSevenZipTails(db, [merged]), 2)
|
|
const left = await db.from('probe_candidates').orderBy('message_id').select('message_id')
|
|
assert.deepEqual(left.map((c) => c.message_id), ['<3@x>', '<4@x>', '<5@x>', '<6@x>', '<7@x>', '<8@x>'])
|
|
})
|
|
})
|