Spotnet (CONCEPT D29): - Index free.pt fully and import spots with their descriptions, categories and NZBs; a spot renames its release, since Spotnet names are more trustworthy than names derived from subjects. - Find passwords in spot descriptions too, and tell "needs a password we have" from "needs a password we don't have". Content inspection: - List the contents of 7z (.7z.001) archives, SFV sets, nicovideo uploads and other archive-like files; mark yEncBin .bin containers as encrypted. - Take real names from yEnc headers for randomly named files, and merge uploads that were split across posts. Storage (D31, D32): - Store segment lists zstd-compressed behind the FileStore accessor. - group:backfill indexes older headers at low priority and pauses when the NVMe or HDD part of the database gets too large. Grouping (D35, D36): - Lone header segments wait in staged_segments until a second segment of their file arrives, which drops the per-article junk binaries. - Counter grouping joins random-subject uploads by poster, [i/M] counter, part count and day. Search and maintenance (D33, D34): - A trigram-indexed search_text column, smaller indexes, estimated stats. - Passes that clean up nonsense names; weekly index maintenance; GC budgets per kind. - Web UI: grey out stale results while a search runs and cancel superseded requests. Count only up to 1,000 matches for the page, which made filter clicks take seconds (Newznab keeps the 10,000 cap). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
3.6 KiB
TypeScript
71 lines
3.6 KiB
TypeScript
import { test } from '@japa/runner'
|
|
import db from '@adonisjs/lucid/services/db'
|
|
import testUtils from '@adonisjs/core/services/test_utils'
|
|
import StagingService from '#services/StagingService'
|
|
import IngestService, { segmentFromHeader } from '#services/IngestService'
|
|
import { counterFileKey } from '#lib/subject/index'
|
|
|
|
let n = 0
|
|
/** An article of a random-subject upload: a new random name every time. */
|
|
const randomArticle = (k: number, total = 4, { counter = '[21/62]', date = 'Thu, 01 Oct 2026 12:00:00 GMT', id }: { counter?: string; date?: string; id?: string } = {}) =>
|
|
segmentFromHeader(
|
|
{ 'subject': `${counter} "Rnd${++n}xQ7kLm2Pz9Wv4Ty8Ab3Cd" yEnc (${k}/${total})`, 'from': 'bob@home.com', 'message-id': `<${id ?? `art${n}`}@nyuu>`, 'date': date, ':bytes': '700000' },
|
|
'alt.binaries.boneless',
|
|
k
|
|
)!
|
|
|
|
async function ingestBatch(segments: ReturnType<typeof randomArticle>[], counters = true) {
|
|
const r = await StagingService.filter(segments, { counters })
|
|
await IngestService.ingest(r.ingest)
|
|
return r
|
|
}
|
|
|
|
test.group('Counter grouping', (group) => {
|
|
group.each.setup(() => testUtils.db().withGlobalTransaction())
|
|
|
|
test('articles with random subjects become one file by poster, counter and part count', async ({ assert }) => {
|
|
const key = counterFileKey(randomArticle(1))!
|
|
await ingestBatch([randomArticle(1)])
|
|
assert.isNull(await db.from('binaries').where('file_key', key).first())
|
|
await ingestBatch([randomArticle(2)])
|
|
const binary = await db.from('binaries').where('file_key', key).first()
|
|
assert.isNotNull(binary)
|
|
// Later articles join the file directly, until it completes.
|
|
await ingestBatch([randomArticle(3)])
|
|
await ingestBatch([randomArticle(4)])
|
|
const parts = await db.from('parts').where('binary_id', binary.id).orderBy('number').select('number')
|
|
assert.deepEqual(parts.map((p) => p.number), [1, 2, 3, 4])
|
|
assert.isNotNull((await db.from('binaries').where('id', binary.id).first()).completed_at)
|
|
})
|
|
|
|
test('off by default; another day is another file; a repeated part number is a conflict', async ({ assert }) => {
|
|
await ingestBatch([randomArticle(1, 9, { counter: '[05/10]' })], false)
|
|
await ingestBatch([randomArticle(2, 9, { counter: '[05/10]' })], false)
|
|
assert.isNull(await db.from('binaries').where('file_key', counterFileKey(randomArticle(1, 9, { counter: '[05/10]' }))!).first())
|
|
|
|
const other = randomArticle(1, 9, { counter: '[06/10]', date: 'Fri, 02 Oct 2026 12:00:00 GMT' })
|
|
assert.notEqual(counterFileKey(other), counterFileKey(randomArticle(1, 9, { counter: '[06/10]' })))
|
|
|
|
// Two uploads of the same shape on one day: part 1 twice, from different articles.
|
|
await ingestBatch([randomArticle(1, 9, { counter: '[07/10]' })])
|
|
await ingestBatch([randomArticle(2, 9, { counter: '[07/10]' })])
|
|
await ingestBatch([randomArticle(1, 9, { counter: '[07/10]' })])
|
|
const binary = await db.from('binaries').where('file_key', counterFileKey(randomArticle(1, 9, { counter: '[07/10]' }))!).first()
|
|
assert.isNotNull(binary.conflicted_at)
|
|
})
|
|
|
|
test('a normal file with a counter stays a normal file', async ({ assert }) => {
|
|
const normal = (k: number) =>
|
|
segmentFromHeader(
|
|
{ 'subject': `[07/45] - "Some.Release.part06.rar" yEnc (${k}/3)`, 'from': 'poster@x', 'message-id': `<norm${k}@x>`, 'date': 'Thu, 01 Oct 2026 12:00:00 GMT', ':bytes': '700000' },
|
|
'alt.binaries.test',
|
|
k
|
|
)!
|
|
await ingestBatch([normal(1)])
|
|
await ingestBatch([normal(2), normal(3)])
|
|
const binary = await db.from('binaries').where('name', 'Some.Release.part06.rar').first()
|
|
assert.equal(binary.file_key, normal(1).fileKey)
|
|
assert.isNotNull(binary.completed_at)
|
|
})
|
|
})
|