From 4ed7f899514311f7e3e63108e15cf395ecafff56 Mon Sep 17 00:00:00 2001 From: Daan Meijer Date: Sun, 11 Oct 2026 15:44:08 +0200 Subject: [PATCH] Prober: no packaging or release-name-plus-extension as inner name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lone candidates are often par2 volumes of random-named sets ("42507096….vol007+08.par2"): their yEnc name was taken as the inner name. Packaging names are skipped for lone files too, and a name that starts with the release's own name says nothing new. Co-Authored-By: Claude Opus 5.5 --- lib/probe/inspect.ts | 5 +++-- tests/unit/probe/inspect.spec.ts | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/probe/inspect.ts b/lib/probe/inspect.ts index 69a4950..4f5384f 100644 --- a/lib/probe/inspect.ts +++ b/lib/probe/inspect.ts @@ -76,7 +76,8 @@ export function inspect(body: Buffer): Inspection { export function innerName(inspections: { kind: string; result: Inspection }[], releaseName = ''): string | null { const of = (kind: string) => inspections.filter((i) => i.kind === kind).map((i) => i.result) const content = (kind: string) => of(kind).flatMap((i) => i.names ?? []).find((n) => !PACKAGING.test(n)) - const pick = content('archive') ?? content('par2') ?? of('lone').find((i) => i.yencName)?.yencName + const pick = content('archive') ?? content('par2') ?? of('lone').find((i) => i.yencName && !PACKAGING.test(i.yencName))?.yencName const name = pick?.replace(/^.*[\\/]/, '').slice(0, 255) - return name && name.toLowerCase() !== releaseName.toLowerCase() ? name : null + // The release's own name with an extension says nothing new (a random-named file's yEnc name is mostly its random name). + return name && !name.toLowerCase().startsWith(releaseName.toLowerCase() || '\0') ? name : null } diff --git a/tests/unit/probe/inspect.spec.ts b/tests/unit/probe/inspect.spec.ts index b0adfcf..0b97080 100644 --- a/tests/unit/probe/inspect.spec.ts +++ b/tests/unit/probe/inspect.spec.ts @@ -123,5 +123,8 @@ test.group('probe / innerName', () => { assert.equal(innerName([lone], 'k3j4h5'), 'Real.Name.mkv') // A random-named file whose yEnc name is its random name says nothing new. assert.isNull(innerName([lone], 'real.name.mkv')) + assert.isNull(innerName([lone], 'Real.Name')) + // Nor does packaging: a lone par2 volume. + assert.isNull(innerName([{ kind: 'lone', result: { yencName: 'a1b2.vol007+08.par2', size: 1, type: 'par2' } }], 'x9y8')) }) })