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')) }) })