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>
72 lines
3.2 KiB
TypeScript
72 lines
3.2 KiB
TypeScript
import { test } from '@japa/runner'
|
|
import {
|
|
checkHeader,
|
|
listingStart,
|
|
parseBsdtarListing,
|
|
parseSevenZipStart,
|
|
readNumber,
|
|
sevenZipVolume,
|
|
} from '#lib/sevenzip/index'
|
|
|
|
// `7z a tiny.7z Tiny.Release` (Tiny.Release/a.txt): an LZMA-encoded header.
|
|
const ENCODED = Buffer.from(
|
|
'N3q8ryccAATeIVLCfQAAAAAAAAAhAAAAAAAAAGkLW/MBAAtoZWxsbyB3b3JsZAoAAACBMweuD87ysgwHyEN/QbH6/duIttdfpOXRhZbi6t7tycGOUDyW1l2aTE7xmuZ/NAXKgg599VxKYAF1XImsfT9LzHQKaEH6PEZambLnwJM62mXXEJIpaYvhCrHFeQv+jLnYjgJMfwZEcAAAABcGEAEJbQAHCwEAASMDAQEFXQAQAAAMgJYKASTou9wAAA==',
|
|
'base64'
|
|
)
|
|
// The same with -mhc=off: a plain header.
|
|
const PLAIN = Buffer.from(
|
|
'N3q8ryccAASpRwRsEAAAAAAAAACWAAAAAAAAACTou9wBAAtoZWxsbyB3b3JsZAoAAQQGAAEJEAAHCwEAASEhAQAMDAAICgEtOwivAAAFAg4BgBkJAAAAAAAAAAAAEUEAVABpAG4AeQAuAFIAZQBsAGUAYQBzAGUAAABUAGkAbgB5AC4AUgBlAGwAZQBhAHMAZQAvAGEALgB0AHgAdAAAABkCAAAUEgEA/QYYLBBR3QH9BhgsEFHdARUKAQAQgP1BIIC0gQAA',
|
|
'base64'
|
|
)
|
|
|
|
test.group('sevenzip', () => {
|
|
test('finds the header at the end from the signature header', ({ assert }) => {
|
|
const start = parseSevenZipStart(ENCODED)!
|
|
assert.deepEqual(start, { headerStart: 157, headerSize: 33, headerCrc: start.headerCrc, archiveSize: 190 })
|
|
const header = ENCODED.subarray(start.headerStart, start.archiveSize)
|
|
assert.isTrue(checkHeader(start, header))
|
|
assert.isFalse(checkHeader(start, Buffer.alloc(33)))
|
|
// Encoded: the packed header right after the file data (packPos 16) is needed too.
|
|
assert.equal(listingStart(start, header), 48)
|
|
|
|
const plain = parseSevenZipStart(PLAIN)!
|
|
assert.equal(plain.archiveSize, PLAIN.length)
|
|
assert.equal(listingStart(plain, PLAIN.subarray(plain.headerStart)), plain.headerStart)
|
|
})
|
|
|
|
test('rejects other data and a damaged signature header', ({ assert }) => {
|
|
assert.isNull(parseSevenZipStart(Buffer.from('Rar!\x1a\x07\x01\x00'.padEnd(40, '\0'), 'latin1')))
|
|
const damaged = Buffer.from(ENCODED)
|
|
damaged[14] ^= 1
|
|
assert.isNull(parseSevenZipStart(damaged))
|
|
})
|
|
|
|
test('reads 7z numbers', ({ assert }) => {
|
|
assert.deepEqual(readNumber(Buffer.from([0x10]), 0), [16, 1])
|
|
assert.deepEqual(readNumber(Buffer.from([0x81, 0x02]), 0), [0x102, 2])
|
|
assert.deepEqual(readNumber(Buffer.from([0xc0, 0x34, 0x12]), 0), [0x1234, 3])
|
|
assert.deepEqual(readNumber(Buffer.from([0xff, 1, 0, 0, 0, 0, 0, 0, 0]), 0), [1, 9])
|
|
})
|
|
|
|
test('parses bsdtar listings', ({ assert }) => {
|
|
const out = [
|
|
'drwxrwxr-x 0 0 0 0 Sep 30 19:13 Some.Release.2026/',
|
|
'-rw-rw-r-- 0 0 0 3000000 Sep 30 19:13 Some.Release.2026/movie.mkv',
|
|
'-rw-rw-r-- 0 0 0 3 Jan 1 2019 Some.Release.2026/some info.nfo',
|
|
'',
|
|
].join('\n')
|
|
assert.deepEqual(parseBsdtarListing(out), [
|
|
{ name: 'Some.Release.2026', size: 0, directory: true },
|
|
{ name: 'Some.Release.2026/movie.mkv', size: 3000000, directory: false },
|
|
{ name: 'Some.Release.2026/some info.nfo', size: 3, directory: false },
|
|
])
|
|
})
|
|
|
|
test('numbers volumes', ({ assert }) => {
|
|
assert.equal(sevenZipVolume('x.7z.001'), 1)
|
|
assert.equal(sevenZipVolume('X.7Z.012'), 12)
|
|
assert.equal(sevenZipVolume('x.7z'), 0)
|
|
assert.isNull(sevenZipVolume('x.part01.rar'))
|
|
})
|
|
})
|