Files
usenet-indexer/lib/release/source.ts
T
Daan MeijerandClaude Fable 5.1 2580f20a43
Test and deploy / test (push) Successful in 51s
Test and deploy / edge (push) Successful in 1m48s
Test and deploy / deploy (push) Skipped
voyager 3: the batch store writes releases once, by id references and bytea keys
Each release chunk is a release inserted once: release_key the SHA-1 of
the identity, the owner group and the first article (deterministic; no
numbering under a group lock), identity_key the identity's SHA-1 bytes,
poster_id and group_set_id through catalog_refs (cached per process),
source as a code (weak-stem added), the name into release_texts. A
finished release's candidates are claimable at once; a provisional tail
release is finished by a later chunk of its key, a finished one sent again
is left alone. Gone: joins into earlier releases and across groups, key
numbering, the group lock, the fragment merger. Interim: chunks, counts
and samples keyed by ranges.block_id, a range without a block gets one.

Readers follow: search (posters and group_sets joined, words through
release_texts, posters by id, source by code), the par2 merger, the
sidecar folder, the judge's scraped rule, the spot inspector, the spotter,
the NZB service, releases:regroup, edge:bench. Tests insert fixtures
through tests/functional/helpers/releases.ts; the suites pass again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 21:04:03 +01:00

39 lines
1.5 KiB
TypeScript

/**
* How a release got its name, as releases.source stores it (a smallint; voyager 3, migration 6000). The names are
* what the edge, the spot inspector and the API use; the numbers never change meaning once written.
*/
export const SOURCES = {
/** A name the subject announces ("name" yEnc (k/N)). */
subject: 1,
/** The post's files, named after the first file (no release name in the subject). */
post: 2,
/** The files' shared stem. */
stem: 3,
/** A Spotnet spot's files that matched no release. */
spot: 4,
/** An NZB's files. */
nzb: 5,
/** One poster's files that differ only by a number sequence, or share a prefix (voyager 3). */
album: 6,
/** An obfuscated post's stem, read from the yEnc body (identity.ts: weak). */
'weak-stem': 7,
} as const
export type Source = keyof typeof SOURCES
const NAMES = Object.fromEntries(
Object.entries(SOURCES).map(([name, code]) => [code, name])
) as Record<number, Source>
/** The code of a source name; throws for an unknown one (a typo would write a wrong number for good). */
export function sourceCode(name: string): number {
const code = SOURCES[name as Source]
if (code === undefined) throw new Error(`Unknown release source "${name}"`)
return code
}
/** The name of a stored code; "unknown" for one not listed (never written, but a row might be read by an older build). */
export function sourceName(code: number | string | null | undefined): Source | 'unknown' {
return NAMES[Number(code)] ?? 'unknown'
}