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>
60 lines
3.0 KiB
TypeScript
60 lines
3.0 KiB
TypeScript
import { test } from '@japa/runner'
|
|
import db from '@adonisjs/lucid/services/db'
|
|
import testUtils from '@adonisjs/core/services/test_utils'
|
|
import FileStore from '#services/FileStore'
|
|
import SfvService from '#services/SfvService'
|
|
import { parseSfv } from '#lib/content/index'
|
|
|
|
const POSTER = 'Snazzy Poster <me@localhost.localdomain>'
|
|
|
|
let keys = 0
|
|
async function release(name: string, source = 'stem') {
|
|
const now = new Date()
|
|
const [r] = await db
|
|
.table('releases')
|
|
.insert({ release_key: `sfv${++keys}`.padEnd(40, 'x'), name, source, groups: '[]', first_seen_at: now, last_seen_at: now })
|
|
.returning('id')
|
|
return Number(r.id)
|
|
}
|
|
|
|
async function file(name: string, releaseId: number, poster = POSTER) {
|
|
const [{ id }] = await FileStore.insert([
|
|
{ filename: name, poster, date: Date.now(), parts: 1, size: 10, release_id: releaseId, groups: '[]',
|
|
segments: [{ number: 1, id: `${name}@x`, size: 10 }], created_at: new Date(), updated_at: new Date() },
|
|
])
|
|
return db.from('files').where('id', id).first()
|
|
}
|
|
|
|
test.group('SFV grouping', (group) => {
|
|
group.each.setup(() => testUtils.db().withGlobalTransaction())
|
|
|
|
test('parses SFV listings', ({ assert }) => {
|
|
assert.deepEqual(parseSfv('; made by x\r\n01-a-b-4066667a.flac 4066667A\r\n"02 c.flac" 5058F120\r\n\r\n'), [
|
|
{ name: '01-a-b-4066667a.flac', crc: '4066667a' },
|
|
{ name: '02 c.flac', crc: '5058f120' },
|
|
])
|
|
})
|
|
|
|
test("gathers an album's tracks into the SFV's release, named after the album; later tracks join too", async ({ assert }) => {
|
|
const album = await release('00-graham_barham-club_country_(after_party)-16bit-web-flac-2026')
|
|
const sfv = await file('00-graham_barham-club_country_(after_party)-16bit-web-flac-2026.sfv', album)
|
|
const track1 = await release('01-graham_barham-country_music-4066667a')
|
|
await file('01-graham_barham-country_music-4066667a.flac', track1)
|
|
// Another poster's file with the same name stays.
|
|
const other = await release('01-graham_barham-country_music-4066667a', 'stem')
|
|
const foreign = await file('01-graham_barham-country_music-4066667a.flac', other, 'someone@else')
|
|
|
|
const listing = '01-graham_barham-country_music-4066667a.flac 4066667a\n02-graham_barham-sippin-5058f120.flac 5058f120\n'
|
|
assert.equal(await SfvService.attach(sfv, listing), 1)
|
|
const renamed = await db.from('releases').where('id', album).first()
|
|
assert.equal(renamed.name, 'graham_barham-club_country_(after_party)-16bit-web-flac-2026')
|
|
assert.equal((await db.from('files').where('id', foreign.id).first()).release_id, other)
|
|
|
|
// Track 2 completes after the SFV was read.
|
|
const track2 = await release('02-graham_barham-sippin-5058f120')
|
|
const late = await file('02-graham_barham-sippin-5058f120.flac', track2)
|
|
assert.equal(await SfvService.claim({ id: late.id, name: late.filename, poster: late.poster, date: Number(late.date), release_id: track2 }), album)
|
|
assert.equal((await db.from('releases').where('id', album).first()).file_count, 3)
|
|
})
|
|
})
|