fix: reconcile stale staged updates
TallyNote release / linux-x64 (push) Successful in 6m50s

This commit is contained in:
Qiufeng
2026-09-05 16:31:53 +08:00
parent efbd0e0d87
commit 6c96cddd4e
4 changed files with 20 additions and 5 deletions
+3 -1
View File
@@ -58,6 +58,7 @@ import { isNewerVersion } from "./update.js";
import {
ACTIVE_UPDATE_STATUSES,
checkForUpdate,
currentReleaseVersion,
publicCheckFromCache,
publicUpdateJob,
reconcileOrphanedUpdateJobs,
@@ -1016,7 +1017,8 @@ export async function buildApp(database: DatabaseContext, config: AppConfig) {
// A package may have been downloaded before the host was upgraded by
// another path. Never apply a staged archive that is no longer newer
// than the release currently serving traffic.
if (!isNewerVersion(config.appVersion, staged.version)) {
const effectiveCurrentVersion = currentReleaseVersion(config) ?? config.appVersion;
if (!isNewerVersion(effectiveCurrentVersion, staged.version)) {
const now = Date.now();
database.sqlite.prepare("UPDATE update_jobs SET status='failed', error_message=?, completed_at=?, updated_at=? WHERE id=? AND status='staged'").run("暂存更新已过期,当前版本无需再次升级", now, now, stagedJobId);
throw new AppError(409, "UPDATE_NOT_AVAILABLE", "暂存更新已过期,请重新检查更新");