mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: poll restart status during WebUI update
This commit is contained in:
@@ -5,7 +5,7 @@ import os
|
||||
from astrbot.core.computer.booters.cua_defaults import CUA_DEFAULT_CONFIG
|
||||
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
|
||||
|
||||
VERSION = "4.25.6-rc.1"
|
||||
VERSION = "4.25.6-rc.2"
|
||||
DB_PATH = os.path.join(get_astrbot_data_path(), "data_v4.db")
|
||||
PERSONAL_WECHAT_CONFIG_METADATA = {
|
||||
"weixin_oc_base_url": {
|
||||
|
||||
@@ -55,6 +55,7 @@ let showAdvancedUpdateSettings = ref(false);
|
||||
let restartWaiting = ref(false);
|
||||
let restartStartTime = ref<number | string | null>(null);
|
||||
let restartPollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
const RESTART_START_TIME_POLL_INTERVAL_MS = 2000;
|
||||
type DownloadStageStatus = "pending" | "running" | "done" | "error";
|
||||
type DownloadStage = {
|
||||
status: DownloadStageStatus;
|
||||
@@ -569,20 +570,25 @@ async function fetchAstrBotStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
function waitForAstrBotRestart(initialStartTime: number | string | null) {
|
||||
if (restartWaiting.value) {
|
||||
function waitForAstrBotRestart(
|
||||
initialStartTime: number | string | null,
|
||||
showWaiting = true,
|
||||
) {
|
||||
if (showWaiting && !restartWaiting.value) {
|
||||
restartWaiting.value = true;
|
||||
updateProgress.value = {
|
||||
...updateProgress.value,
|
||||
stage: "restart",
|
||||
status: "success",
|
||||
message: t("core.header.updateDialog.progress.restarting"),
|
||||
overall_percent: 100,
|
||||
};
|
||||
}
|
||||
if (restartPollTimer) {
|
||||
return;
|
||||
}
|
||||
stopRestartPolling();
|
||||
restartWaiting.value = true;
|
||||
|
||||
restartStartTime.value = initialStartTime;
|
||||
updateProgress.value = {
|
||||
...updateProgress.value,
|
||||
stage: "restart",
|
||||
status: "success",
|
||||
message: t("core.header.updateDialog.progress.restarting"),
|
||||
overall_percent: 100,
|
||||
};
|
||||
|
||||
const poll = async () => {
|
||||
try {
|
||||
@@ -601,9 +607,10 @@ function waitForAstrBotRestart(initialStartTime: number | string | null) {
|
||||
}
|
||||
};
|
||||
|
||||
void poll();
|
||||
restartPollTimer = setInterval(() => {
|
||||
void poll();
|
||||
}, 1000);
|
||||
}, RESTART_START_TIME_POLL_INTERVAL_MS);
|
||||
}
|
||||
|
||||
function applyUpdateProgress(payload: UpdateProgress) {
|
||||
@@ -619,6 +626,9 @@ function applyUpdateProgress(payload: UpdateProgress) {
|
||||
installLoading.value = false;
|
||||
stopUpdateProgressPolling();
|
||||
}
|
||||
if (payload.status === "error") {
|
||||
stopRestartPolling();
|
||||
}
|
||||
if (payload.stage === "restart") {
|
||||
waitForAstrBotRestart(restartStartTime.value);
|
||||
}
|
||||
@@ -667,6 +677,7 @@ async function switchVersion(targetVersion: string) {
|
||||
initialStartTime = commonStore.getStartTime();
|
||||
}
|
||||
restartStartTime.value = initialStartTime;
|
||||
waitForAstrBotRestart(initialStartTime, false);
|
||||
startUpdateProgressPolling(progressId);
|
||||
|
||||
axios
|
||||
@@ -691,6 +702,12 @@ async function switchVersion(targetVersion: string) {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
stopUpdateProgressPolling();
|
||||
if (!err?.response && restartPollTimer) {
|
||||
waitForAstrBotRestart(restartStartTime.value);
|
||||
updateStatus.value = t("core.header.updateDialog.progress.restarting");
|
||||
return;
|
||||
}
|
||||
stopRestartPolling();
|
||||
installLoading.value = false;
|
||||
updateStatus.value = err;
|
||||
updateProgress.value = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "AstrBot"
|
||||
version = "4.25.6-rc.1"
|
||||
version = "4.25.6-rc.2"
|
||||
description = "Easy-to-use multi-platform LLM chatbot and development framework"
|
||||
readme = "README.md"
|
||||
license = { text = "AGPL-3.0-or-later" }
|
||||
|
||||
Reference in New Issue
Block a user