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:
1 parent
5a78b1fdf8
commit
31f4fedafe
11 files changed
+173
-101
No files matched your search
@@ -23,7 +23,7 @@ import {
|
||||
import type { ActivePatchSet, PackApplyResult, PackCheck, PackProblem, PackRelease } from '@shared/schemas/patch-pack.ts';
|
||||
import { bundledResourcePaths, usesDownloadedPacks } from '../resources/resource-paths.ts';
|
||||
import { activeDownloadedPack, installPack, useBundledPatchSet } from './pack-store.ts';
|
||||
import { downloadReleaseFile, FeedUnreachableError, newestPackRelease, type PackReleaseFiles } from './release-feed.ts';
|
||||
import { downloadReleaseFile, FeedUnreachableError, newestProjectRelease, ReleasePageLimitError, type PackReleaseFiles } from './release-feed.ts';
|
||||
|
||||
/** The manifest copy beside a release is a few hundred bytes. */
|
||||
const MANIFEST_COPY_MAX_BYTES = 64 * 1024;
|
||||
@@ -41,7 +41,7 @@ export async function checkPackUpdate(): Promise<PackCheck> {
|
||||
const active = activePatchSet();
|
||||
if (!packSigningPublicKey()) return { status: 'failed', active, latest: null, problem: 'no_signing_key' };
|
||||
try {
|
||||
const found = await newestRelease();
|
||||
const found = await newestRelease(active.version);
|
||||
if (!found || !isNewer(found.manifest.version, active.version)) return { status: 'up_to_date', active, latest: found ? release(found) : null, problem: null };
|
||||
const status = manifestIncompatibility(found.manifest, app.getVersion()) ? 'needs_app_update' : 'available';
|
||||
return { status, active, latest: release(found), problem: null };
|
||||
@@ -55,7 +55,7 @@ export async function checkPackUpdate(): Promise<PackCheck> {
|
||||
export async function applyPackUpdate(): Promise<PackApplyResult> {
|
||||
if (!packSigningPublicKey()) return { ok: false, problem: 'no_signing_key' };
|
||||
try {
|
||||
const found = await newestRelease();
|
||||
const found = await newestRelease(activePatchSet().version);
|
||||
if (!found || !isNewer(found.manifest.version, activePatchSet().version)) return { ok: false, problem: 'up_to_date' };
|
||||
if (manifestIncompatibility(found.manifest, app.getVersion())) return { ok: false, problem: 'needs_app_update' };
|
||||
const tuning = patchPackTuning();
|
||||
@@ -81,8 +81,8 @@ interface FoundRelease {
|
||||
readonly manifest: PatchPackManifest;
|
||||
}
|
||||
|
||||
async function newestRelease(): Promise<FoundRelease | null> {
|
||||
const files = await newestPackRelease();
|
||||
async function newestRelease(installedVersion: string | null): Promise<FoundRelease | null> {
|
||||
const files = await newestProjectRelease('pack', installedVersion);
|
||||
if (!files) return null;
|
||||
const text = new TextDecoder().decode(await downloadReleaseFile(files.manifestUrl, MANIFEST_COPY_MAX_BYTES));
|
||||
const manifest = parseManifest(text);
|
||||
@@ -116,6 +116,7 @@ function bundledVersion(root: string): string | null {
|
||||
}
|
||||
|
||||
function problemOf(error: unknown): PackProblem {
|
||||
if (error instanceof ReleasePageLimitError) return 'page_limit';
|
||||
if (error instanceof FeedUnreachableError) return 'network';
|
||||
if (error instanceof PatchPackError) {
|
||||
if (error.problem === 'signature') return 'signature';
|
||||
|
||||
Reference in new issue
Block a user