fix(updates): scan release channels across pages

Share a bounded release scan across channels and compare tag versions across pages. Report uncertainty when the scan hits its limit without confirming a newer release.

Verified with local release responses covering cross-page versions, truncation, and missing feeds.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 15:23:18 +08:00
1 parent 5a78b1fdf8
commit 31f4fedafe
11 files changed
+173 -101

No files matched your search

@@ -1,6 +1,6 @@
/** Why an adaptation pack cannot be built, read or used. */
export type PatchPackProblem =
/** tuning/patch-pack.jsonc is invalid. */
/** tuning/release-channels.jsonc is invalid. */
| 'tuning'
/** No signing key, or a key of the wrong kind. */
| 'key'
@@ -1,6 +1,4 @@
/**
* The adaptation pack settings in packages/patcher/tuning/patch-pack.jsonc.
*/
/** Settings shared by the launcher and adaptation pack release checks. */
import { readFileSync } from 'node:fs';
import { parseJsonc } from '@wto/jsonc';
import { PatchPackError } from './patch-pack-error.ts';
@@ -8,13 +6,14 @@ import { PatchPackError } from './patch-pack-error.ts';
export interface PatchPackTuning {
/** `owner/repo` on GitHub. */
readonly repository: string;
readonly releasesPerCheck: number;
readonly releasePageSize: number;
readonly maxReleasePages: number;
readonly maxPackBytes: number;
readonly maxUnpackedBytes: number;
readonly requestTimeoutMs: number;
}
const TUNING_FILE = new URL('../../tuning/patch-pack.jsonc', import.meta.url);
const TUNING_FILE = new URL('../../tuning/release-channels.jsonc', import.meta.url);
let cached: PatchPackTuning | null = null;
@@ -27,9 +26,12 @@ export function patchPackTuning(): PatchPackTuning {
if (typeof repository !== 'string' || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(repository)) {
throw tuningError('"repository" must be "owner/repo"');
}
const releasePageSize = positiveInteger(fields, 'release_page_size');
if (releasePageSize > 100) throw tuningError('"release_page_size" must be at most 100');
cached = {
repository,
releasesPerCheck: positiveInteger(fields, 'releases_per_check'),
releasePageSize,
maxReleasePages: positiveInteger(fields, 'max_release_pages'),
maxPackBytes: positiveInteger(fields, 'max_pack_bytes'),
maxUnpackedBytes: positiveInteger(fields, 'max_unpacked_bytes'),
requestTimeoutMs: positiveInteger(fields, 'request_timeout_ms'),
@@ -39,10 +41,10 @@ export function patchPackTuning(): PatchPackTuning {
function positiveInteger(fields: Record<string, unknown>, key: string): number {
const value = fields[key];
if (typeof value !== 'number' || !Number.isInteger(value) || value <= 0) throw tuningError(`"${key}" must be a positive integer`);
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0) throw tuningError(`"${key}" must be a positive integer`);
return value;
}
function tuningError(detail: string): PatchPackError {
return new PatchPackError('tuning', `tuning/patch-pack.jsonc: ${detail}`);
return new PatchPackError('tuning', `tuning/release-channels.jsonc: ${detail}`);
}
-14
View File
@@ -1,14 +0,0 @@
// Adaptation packs (packages/patcher/src/patch-pack/): where the launcher looks for them and the
// limits it applies to what it downloads.
{
// GitHub repository whose Releases carry the packs (tags `patches-<version>`).
"repository": "N0VAN0M4LY/WT-Offline",
// How many of the newest releases one check reads; packs are found among them.
"releases_per_check": 30,
// Largest pack (zip) the launcher downloads, and the most its files may add up to unpacked.
// The whole patch set is about 0.2 MB today.
"max_pack_bytes": 16777216,
"max_unpacked_bytes": 67108864,
// A request to GitHub that takes longer is given up.
"request_timeout_ms": 20000
}
@@ -0,0 +1,14 @@
// GitHub release checks for the launcher and adaptation packs, including the pack size limits.
{
// Both channels share this repository. Launcher tags use `v<version>` and pack tags use `patches-<version>`.
"repository": "N0VAN0M4LY/WT-Offline",
// Entries per request (GitHub allows up to 100) and pages per shared check.
"release_page_size": 30,
"max_release_pages": 5,
// Largest pack (zip) the launcher downloads, and the most its files may add up to unpacked.
// The whole patch set is about 0.2 MB today.
"max_pack_bytes": 16777216,
"max_unpacked_bytes": 67108864,
// A request to GitHub that takes longer is given up.
"request_timeout_ms": 20000
}