This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tallynote",
|
"name": "tallynote",
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"packageManager": "pnpm@9.0.6",
|
"packageManager": "pnpm@9.0.6",
|
||||||
|
|||||||
+3
-1
@@ -58,6 +58,7 @@ import { isNewerVersion } from "./update.js";
|
|||||||
import {
|
import {
|
||||||
ACTIVE_UPDATE_STATUSES,
|
ACTIVE_UPDATE_STATUSES,
|
||||||
checkForUpdate,
|
checkForUpdate,
|
||||||
|
currentReleaseVersion,
|
||||||
publicCheckFromCache,
|
publicCheckFromCache,
|
||||||
publicUpdateJob,
|
publicUpdateJob,
|
||||||
reconcileOrphanedUpdateJobs,
|
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
|
// A package may have been downloaded before the host was upgraded by
|
||||||
// another path. Never apply a staged archive that is no longer newer
|
// another path. Never apply a staged archive that is no longer newer
|
||||||
// than the release currently serving traffic.
|
// 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();
|
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);
|
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", "暂存更新已过期,请重新检查更新");
|
throw new AppError(409, "UPDATE_NOT_AVAILABLE", "暂存更新已过期,请重新检查更新");
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ function recoveryStateJobId(filePath: string): string | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentReleaseVersion(config: AppConfig): string | null {
|
export function currentReleaseVersion(config: AppConfig): string | null {
|
||||||
try {
|
try {
|
||||||
const target = realpathSync(config.currentLink);
|
const target = realpathSync(config.currentLink);
|
||||||
const releases = realpathSync(config.releasesDir);
|
const releases = realpathSync(config.releasesDir);
|
||||||
@@ -498,7 +498,8 @@ export function reconcileOrphanedUpdateJobs(database: Database.Database, config:
|
|||||||
// completes the same release) before returning to this page. Treat the
|
// completes the same release) before returning to this page. Treat the
|
||||||
// archive as an expired terminal task so it cannot keep blocking the
|
// archive as an expired terminal task so it cannot keep blocking the
|
||||||
// queue or appear as an "apply" action for the current version.
|
// queue or appear as an "apply" action for the current version.
|
||||||
if (row.status === "staged" && !isNewerVersion(config.appVersion, row.version) && !matchingFreshRequest && !matchingFreshState) {
|
const effectiveCurrentVersion = releaseVersion ?? config.appVersion;
|
||||||
|
if (row.status === "staged" && !isNewerVersion(effectiveCurrentVersion, row.version) && !matchingFreshRequest && !matchingFreshState) {
|
||||||
const changed = database.transaction(() => {
|
const changed = database.transaction(() => {
|
||||||
const result = database.prepare(`
|
const result = database.prepare(`
|
||||||
UPDATE update_jobs
|
UPDATE update_jobs
|
||||||
|
|||||||
@@ -451,7 +451,19 @@ export default function UpdatePage({
|
|||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
const result = await api<UpdateInfo>("/api/update/check", { method: "POST" });
|
const result = await api<UpdateInfo>("/api/update/check", { method: "POST" });
|
||||||
mergeInfo(result, true);
|
// A check response is authoritative for release availability. It does
|
||||||
|
// not include a job field, so retain a task only while it is still
|
||||||
|
// actionable; the status endpoint has already reconciled expired
|
||||||
|
// staged tasks before this check runs.
|
||||||
|
setLiveInfo((current) => ({
|
||||||
|
...(current ?? result),
|
||||||
|
...result,
|
||||||
|
job: current?.job && (
|
||||||
|
current.job.status === "completed" ||
|
||||||
|
(current.job.status !== "staged" || current.job.operation !== "download") ||
|
||||||
|
(result.latest?.isNewer === true && result.latest.version === current.job.version)
|
||||||
|
) ? current.job : null,
|
||||||
|
}));
|
||||||
notify?.("版本检查完成", "info");
|
notify?.("版本检查完成", "info");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ApiError && e.status === 429) {
|
if (e instanceof ApiError && e.status === 429) {
|
||||||
|
|||||||
Reference in New Issue
Block a user