Fold sidecars (.nfo, .sfv, .nzb) apart from their upload into it
"Murdoch Mysteries S8D1 [00/80] - \"….nzb\"" beside its "[01/94]" upload was a release of its own (23k sidecar-only releases on the corpus, 15k with the poster's bigger release within 10 minutes). The settler queues small settled releases (fold_candidates); the merger's third pass folds one whose files are all sidecars into the poster's bigger release in the same group within 10 minutes: the one sharing a 4+ letter word with its subject, else the one under the same counter total, else none (via 'sidecar'). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5897d595cf
commit
329c7a1373
6 files changed
+172
-4
No files matched your search
@@ -2,6 +2,8 @@ import { test } from '@japa/runner'
|
||||
import db from '@adonisjs/lucid/services/db'
|
||||
import testUtils from '@adonisjs/core/services/test_utils'
|
||||
import { Par2Merger } from '#services/par2_merger'
|
||||
import { encodeChunk } from '#lib/chunks/index'
|
||||
import ChunkPartitions from '#services/chunk_partitions'
|
||||
|
||||
const hash = (c: string) => c.repeat(32)
|
||||
|
||||
@@ -47,7 +49,7 @@ test.group('Par2Merger', (group) => {
|
||||
await db.table('par2_sets').insert({ set_id: setId, release_id: par2, files: 2 })
|
||||
|
||||
const round = await new Par2Merger().round()
|
||||
assert.deepEqual(round, { sets: 1, merges: 1, releases: 3, stems: 0, stemMerges: 0, stemReleases: 0 })
|
||||
assert.deepEqual(round, { sets: 1, merges: 1, releases: 3, stems: 0, stemMerges: 0, stemReleases: 0, folded: { looked: 0, sidecars: 0, folded: 0 } })
|
||||
const target = await db.from('releases').where('id', b).firstOrFail()
|
||||
assert.equal(target.files, 4)
|
||||
assert.equal(target.segments, 40)
|
||||
@@ -180,4 +182,40 @@ test.group('Par2Merger', (group) => {
|
||||
assert.equal((await new Par2Merger().round()).merges, 0)
|
||||
assert.equal((await db.from('releases').whereIn('id', ids).select('id')).length, 3)
|
||||
})
|
||||
|
||||
test('an .nzb or .nfo apart from its upload is folded into it', async ({ assert }) => {
|
||||
await ChunkPartitions.ensure()
|
||||
const at = new Date('2022-07-08T03:46:00Z')
|
||||
const poster = 'up <up@load.er>'
|
||||
let n = 0
|
||||
const release = async (name: string, files: number, total: number | null, posted: Date, chunkFiles: string[]) => {
|
||||
n++
|
||||
const key = `ff${String(n).padStart(6, '0')}`.padEnd(40, '0')
|
||||
const [row] = await db
|
||||
.table('releases')
|
||||
.insert({ release_key: key, identity_key: key, name, source: 'stem', groups: '[]', group_id: 1, files, file_total: total, poster, posted_at: posted, readable: true, settled_at: posted })
|
||||
.returning('id')
|
||||
const id = Number(row.id)
|
||||
const payload = encodeChunk(chunkFiles.map((f, i) => ({ name: f, poster, subject: `${name} [${String(i).padStart(2, '0')}/${total ?? 0}] - "${f}" yEnc`, postedAt: posted.getTime(), groups: ['a.b.test'], segments: [[1, `${id}-${i}@x`, 1000]] })))
|
||||
await db.table('release_chunks').insert({ release_id: id, range_id: 1, batch_from: 1, files: chunkFiles.length, segments: chunkFiles.length, payload })
|
||||
await db.table('fold_candidates').insert({ release_id: id }).onConflict('release_id').ignore()
|
||||
return id
|
||||
}
|
||||
const upload = await release('Murdoch Mysteries S8D1', 94, 94, at, ['Murdoch Mysteries S8D1.part01.rar', 'Murdoch Mysteries S8D1.part02.rar', 'Murdoch Mysteries S8D1.part03.rar', 'Murdoch Mysteries S8D1.part04.rar'])
|
||||
const other = await release('Another Show S1D1', 50, 50, new Date(at.getTime() + 120_000), ['Another Show S1D1.part01.rar', 'Another Show S1D1.part02.rar', 'Another Show S1D1.part03.rar', 'Another Show S1D1.part04.rar'])
|
||||
const nzb = await release('Murdoch Mysteries S8D1', 1, 80, new Date(at.getTime() + 60_000), ['Murdoch Mysteries S8D1.nzb'])
|
||||
// A picture isn't a sidecar; an nfo an hour later belongs to nothing here.
|
||||
const picture = await release('cover', 1, null, at, ['cover.jpg'])
|
||||
const late = await release('Murdoch Mysteries S8D1', 1, null, new Date(at.getTime() + 3600_000), ['Murdoch Mysteries S8D1.nfo'])
|
||||
|
||||
const round = await new Par2Merger().round()
|
||||
assert.deepEqual(round.folded, { looked: 5, sidecars: 2, folded: 1 })
|
||||
assert.isNull(await db.from('releases').where('id', nzb).first())
|
||||
assert.equal((await db.from('releases').where('id', upload).firstOrFail()).files, 95)
|
||||
assert.equal((await db.from('releases').where('id', other).firstOrFail()).files, 50)
|
||||
assert.isNotNull(await db.from('releases').where('id', picture).first())
|
||||
assert.isNotNull(await db.from('releases').where('id', late).first())
|
||||
assert.equal((await db.from('release_merges').where({ into_id: upload, via: 'sidecar' }).count('* as c'))[0].c, '1')
|
||||
assert.equal((await db.from('fold_candidates').count('* as c'))[0].c, '0')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user