Prober: an inspection per candidate; no inner name that is the release's name
A release can have several candidates of a kind (two RAR sets): keyed by
(release, kind) both landed in one upsert ("ON CONFLICT DO UPDATE
command cannot affect row a second time"), and the batch was lost.
release_inspections is keyed by candidate now; the first run's results
are cleared and probed again. A random-named file's yEnc name is often
its random name: an inner name equal to the release's name is dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8bd6d6aa5f
commit
738402aefa
4 files changed
+53
-22
No files matched your search
+16
-11
@@ -144,23 +144,28 @@ export class Prober {
|
||||
const done = outcomes.filter((o) => o.inspection)
|
||||
if (done.length === 0) return
|
||||
await trx.rawQuery(
|
||||
`INSERT INTO release_inspections (release_id, kind, result)
|
||||
SELECT v.release_id, v.kind, v.result FROM jsonb_to_recordset(?::jsonb) AS v(release_id bigint, kind text, result jsonb)
|
||||
ON CONFLICT (release_id, kind) DO UPDATE SET result = excluded.result, created_at = now()`,
|
||||
[JSON.stringify(done.map((o) => ({ release_id: o.candidate.releaseId, kind: o.candidate.kind, result: o.inspection })))]
|
||||
`INSERT INTO release_inspections (release_id, candidate_id, kind, result)
|
||||
SELECT v.release_id, v.candidate_id, v.kind, v.result FROM jsonb_to_recordset(?::jsonb) AS v(release_id bigint, candidate_id bigint, kind text, result jsonb)
|
||||
ON CONFLICT (release_id, candidate_id) DO UPDATE SET result = excluded.result, created_at = now()`,
|
||||
[JSON.stringify(done.map((o) => ({ release_id: o.candidate.releaseId, candidate_id: o.candidate.id, kind: o.candidate.kind, result: o.inspection })))]
|
||||
)
|
||||
// Each touched release from all its inspections (earlier rounds may have stored its other kinds).
|
||||
// Each touched release from all its inspections (earlier rounds may have stored others).
|
||||
const ids = [...new Set(done.map((o) => o.candidate.releaseId))]
|
||||
const { rows } = await trx.rawQuery(`SELECT release_id, kind, result FROM release_inspections WHERE release_id = ANY(?)`, [ids])
|
||||
const byRelease = new Map<number, Record<string, Inspection>>()
|
||||
const { rows } = await trx.rawQuery(
|
||||
`SELECT i.release_id, i.kind, i.result, r.name FROM release_inspections i JOIN releases r ON r.id = i.release_id WHERE i.release_id = ANY(?)`,
|
||||
[ids]
|
||||
)
|
||||
const byRelease = new Map<number, { name: string; all: { kind: string; result: Inspection }[] }>()
|
||||
for (const r of rows) {
|
||||
const id = Number(r.release_id)
|
||||
byRelease.set(id, { ...byRelease.get(id), [r.kind]: r.result })
|
||||
const entry = byRelease.get(id) ?? { name: r.name as string, all: [] as { kind: string; result: Inspection }[] }
|
||||
entry.all.push({ kind: r.kind, result: r.result })
|
||||
byRelease.set(id, entry)
|
||||
}
|
||||
const updates = [...byRelease].map(([id, all]) => ({
|
||||
const updates = [...byRelease].map(([id, { name, all }]) => ({
|
||||
id,
|
||||
passworded: Object.values(all).some((i) => i.passworded === true),
|
||||
inner_name: innerName(all),
|
||||
passworded: all.some((i) => i.result.passworded === true),
|
||||
inner_name: innerName(all, name),
|
||||
}))
|
||||
await trx.rawQuery(
|
||||
`UPDATE releases r SET passworded = v.passworded, inner_name = v.inner_name, inspected_at = now()
|
||||
|
||||
Reference in new issue
Block a user