mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-11-30 18:42:49 +08:00
fix(updater): guard supervised installs and recover interrupted updates
This commit is contained in:
1 parent
0bc2e6cec8
commit
6273185afa
12 files changed
+191
-14
No files matched your search
@@ -119,6 +119,8 @@ Download the matching `windows-x64.zip`, `linux-x64.tar.gz`, or `linux-arm64.tar
|
||||
|
||||
Linux x64 release packages that match the official `build-release.yml` layout can be upgraded from the administration console. It checks the official GitHub Releases, refuses a package without a matching `SHA256SUMS.txt` entry, replaces only application code and restarts the process. `SHA256SUMS.txt` is an integrity checksum only, not a digital signature. `data/`, `config.json`, `certs/`, installed skins and plugins are preserved. Export a backup before starting. Windows release packages can check for versions, but console apply is disabled until it is verified on a real Windows install; download the new package and replace it manually. Linux arm64 packages can be checked, but console apply is disabled because the in-place swap has not been verified on real arm64 hardware; download the new package and replace it manually. Docker and source deployments cannot apply an update from the console.
|
||||
|
||||
Console installation is limited to foreground Linux x64 packages. Instances managed by systemd, PM2 or Supervisor can still check releases and open release notes, but cannot apply them in the console. Stop the service, replace application files from the new package, and start the service again; preserve `data/`, `config.json` and `certs/`. A detached updater is not independent of the service manager.
|
||||
|
||||
Android APKs for `arm64-v8a`, `armeabi-v7a`, and `x86_64` are also attached. They use debug signing for sideload testing; they are not Google Play packages, and real-device voice still needs validation.
|
||||
|
||||
### From source
|
||||
|
||||
@@ -136,6 +136,8 @@ docker compose up -d
|
||||
|
||||
Linux x64 发布包(已按官方 `build-release.yml` 产物形态验证)可以在管理控制台直接升级:控制台只读取官方 GitHub Releases,缺少匹配的 `SHA256SUMS.txt` 条目时拒绝安装,校验通过后仅替换程序代码并重启进程。`SHA256SUMS.txt` 只是 SHA-256 校验和,不是数字签名。`data/`、`config.json`、`certs/`、已安装的皮肤和插件都会保留。开始前建议先导出备份。Windows 发布包可以检查版本,但控制台应用更新尚未经真实 Windows 环境验证,因此已禁用,请下载新包后手动替换。Linux arm64 发布包可以检查版本,但由于原地替换尚未在真实 arm64 硬件验证,控制台应用已禁用;请下载新版发布包后手动替换。Docker 和源码运行不能在控制台应用更新。
|
||||
|
||||
控制台安装仅限前台运行的 Linux x64 发布包。通过 systemd、PM2 或 Supervisor 托管的实例仍可检查版本和查看发行说明,但不能在控制台直接安装。请停止服务,替换新发布包中的程序文件后再启动,并保留 `data/`、`config.json` 和 `certs/`。升级助手即使以独立子进程启动,也仍受服务管理器控制。
|
||||
|
||||
Release 同时提供 Android `arm64-v8a`、`armeabi-v7a` 和 `x86_64` APK。它们使用 debug 签名,可手动侧载测试;不是 Google Play 发布包,Android 真机语音仍需验收。
|
||||
|
||||
### 源码运行
|
||||
|
||||
@@ -16,7 +16,7 @@ backups="$data_dir/updates/backups"
|
||||
|
||||
# Only executable code is swapped by the updater. data/, config.json, certs/,
|
||||
# identities, skins and plugins are deliberately never listed here.
|
||||
code_entries="dist web/dist node_modules runtime package.json package-lock.json README.md LICENSE config.example.json"
|
||||
code_entries="dist web/dist node_modules runtime package.json package-lock.json README.md LICENSE config.example.json start-webspeak.cmd"
|
||||
required_entries="dist/index.js web/dist/index.html node_modules package.json runtime/node"
|
||||
|
||||
code_missing() {
|
||||
@@ -38,6 +38,20 @@ backup_is_complete() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# During the first phase of a swap, only some old entries have been moved.
|
||||
# The rest still live at the install root. The current task can be recovered
|
||||
# from that union, including a kill between rename and manifest persistence.
|
||||
# Never combine a stale task's partial backup with this install.
|
||||
task_backup_can_repair() {
|
||||
[ -f "$1/.webspeak-swap.json" ] || return 1
|
||||
for entry in $required_entries; do
|
||||
if [ ! -e "$1/$entry" ] && [ ! -e "$entry" ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
restore_from_backup() {
|
||||
backup="$1"
|
||||
# Move whatever partial new code the interrupted swap left in the install
|
||||
@@ -85,7 +99,7 @@ if code_missing; then
|
||||
esac
|
||||
if [ -n "$task_id" ]; then
|
||||
candidate="$backups/$task_id"
|
||||
if backup_is_complete "$candidate"; then
|
||||
if task_backup_can_repair "$candidate"; then
|
||||
restore_backup="$candidate"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -125,9 +125,10 @@ export function setCodeSwapCopyForTests(copy: CopyEntry | null): void {
|
||||
*/
|
||||
const SWAP_BARRIER_ENV = "WEBSPEAK_TEST_SWAP_BARRIER_DIR";
|
||||
|
||||
function swapWindowBarrier(): void {
|
||||
function swapWindowBarrier(entry?: string): void {
|
||||
const directory = process.env[SWAP_BARRIER_ENV];
|
||||
if (!directory || !existsSync(directory)) return;
|
||||
if ((process.env.WEBSPEAK_TEST_SWAP_BARRIER_AFTER_ENTRY ?? "") !== (entry ?? "")) return;
|
||||
writeFileSync(path.join(directory, "swap-window-reached"), String(process.pid));
|
||||
const resume = path.join(directory, "resume");
|
||||
const deadline = Date.now() + 30_000;
|
||||
@@ -204,6 +205,7 @@ export function swapCode(rootDir: string, stagedRoot: string, backupDir: string)
|
||||
if (!existsSync(path.join(rootDir, entry))) continue;
|
||||
moveIfPresent(path.join(rootDir, entry), path.join(backupDir, entry));
|
||||
movedToBackup.push(entry);
|
||||
swapWindowBarrier(entry);
|
||||
writeSwapManifest(backupDir, movedToBackup);
|
||||
}
|
||||
swapWindowBarrier();
|
||||
|
||||
@@ -4,8 +4,14 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import {
|
||||
assetKindFor, detectDeployment, isReleasePackageRoot, releaseAssetName, upgradePathFor,
|
||||
assetKindFor, detectDeployment as detectRealDeployment, isReleasePackageRoot, releaseAssetName, runningUnderSupervisor, upgradePathFor,
|
||||
} from "./deployment.js";
|
||||
import type { DeploymentDetectionOptions } from "./deployment.js";
|
||||
|
||||
// Tests may themselves run inside the CI runner's systemd service.
|
||||
function detectDeployment(options: DeploymentDetectionOptions) {
|
||||
return detectRealDeployment({ isSupervised: false, ...options });
|
||||
}
|
||||
|
||||
function temporary(t: test.TestContext): string {
|
||||
const directory = mkdtempSync(path.join(tmpdir(), "webspeak-deployment-"));
|
||||
@@ -154,3 +160,23 @@ test("unsupported platforms are visible but cannot apply", t => {
|
||||
assert.equal(darwin.applyAllowed, false);
|
||||
assert.equal(darwin.reasonCode, "PLATFORM_UNSUPPORTED");
|
||||
});
|
||||
|
||||
test("supervised packages cannot apply even with a release-package override", t => {
|
||||
const root = releasePackageRoot(t);
|
||||
for (const env of [{ INVOCATION_ID: "unit-invocation" }, { pm_id: "0" }, { SUPERVISOR_PROCESS_NAME: "webspeak" }]) {
|
||||
assert.equal(runningUnderSupervisor(env, ""), true);
|
||||
const deployment = detectDeployment({ rootDir: root, platform: "linux", architecture: "x64", isDocker: false,
|
||||
isSupervised: undefined, env: { ...env, WEBSPEAK_DEPLOYMENT_MODE: "release-package" } });
|
||||
assert.equal(deployment.mode, "release-package");
|
||||
assert.equal(deployment.applyAllowed, false);
|
||||
assert.equal(deployment.reasonCode, "DEPLOYMENT_SUPERVISED");
|
||||
assert.equal(deployment.assetKind, "linux-x64");
|
||||
}
|
||||
});
|
||||
|
||||
test("service cgroups are detected without blocking interactive user scopes", () => {
|
||||
assert.equal(runningUnderSupervisor({}, "0::/system.slice/webspeak.service\n"), true);
|
||||
assert.equal(runningUnderSupervisor({}, "0::/user.slice/user-1000.slice/user@1000.service/app.slice/webspeak.service\n"), true);
|
||||
assert.equal(runningUnderSupervisor({}, "0::/user.slice/user-1000.slice/user@1000.service/app.slice/terminal.scope\n"), false);
|
||||
assert.equal(runningUnderSupervisor({}, "0::/\n"), false);
|
||||
});
|
||||
@@ -9,6 +9,8 @@ export interface DeploymentDetectionOptions {
|
||||
env?: NodeJS.ProcessEnv;
|
||||
/** Test seam; omitted means inspect the real container markers. */
|
||||
isDocker?: boolean;
|
||||
/** Test seam; omitted means inspect service-manager environment and cgroups. */
|
||||
isSupervised?: boolean;
|
||||
}
|
||||
|
||||
export interface DeploymentInfo extends UpdateDeploymentView {
|
||||
@@ -51,6 +53,12 @@ export function detectDeployment(options: DeploymentDetectionOptions): Deploymen
|
||||
// "unverified" is never rendered as "can apply" in the UI.
|
||||
applyAllowed = false;
|
||||
reasonCode = "LINUX_ARM64_APPLY_UNVERIFIED";
|
||||
} else if (options.isSupervised ?? runningUnderSupervisor(env)) {
|
||||
// A detached child stays inside its systemd cgroup, and other supervisors
|
||||
// can restart the old app while the runner is swapping it. Until there is
|
||||
// a supervisor-aware handoff, only foreground packages may apply updates.
|
||||
applyAllowed = false;
|
||||
reasonCode = "DEPLOYMENT_SUPERVISED";
|
||||
}
|
||||
return {
|
||||
mode,
|
||||
@@ -63,6 +71,18 @@ export function detectDeployment(options: DeploymentDetectionOptions): Deploymen
|
||||
};
|
||||
}
|
||||
|
||||
export function runningUnderSupervisor(env: NodeJS.ProcessEnv = process.env, cgroup?: string): boolean {
|
||||
if (["INVOCATION_ID", "JOURNAL_STREAM", "NOTIFY_SOCKET", "SYSTEMD_EXEC_PID", "pm_id", "PM2_HOME", "SUPERVISOR_ENABLED", "SUPERVISOR_PROCESS_NAME"]
|
||||
.some((name) => Boolean(env[name]?.trim()))) return true;
|
||||
if (cgroup === undefined) {
|
||||
try { cgroup = readFileSync("/proc/self/cgroup", "utf8"); }
|
||||
catch { return false; }
|
||||
}
|
||||
// The user manager itself is not the app's supervisor: interactive shells
|
||||
// also run below user@UID.service. App-specific services still count.
|
||||
return cgroup.split(/[\n/]/).some((part) => part.endsWith(".service") && !/^user@\d+\.service$/.test(part));
|
||||
}
|
||||
|
||||
export function runningInContainer(env: NodeJS.ProcessEnv = process.env): boolean {
|
||||
if (env.WEBSPEAK_DEPLOYMENT_MODE?.trim().toLowerCase() === "docker") return true;
|
||||
if (existsSync("/.dockerenv")) return true;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { UpdateService } from "./update-service.js";
|
||||
import { CODE_ENTRIES } from "./code-swap.js";
|
||||
|
||||
const SOURCE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO_ROOT = path.resolve(SOURCE_DIR, "..", "..");
|
||||
@@ -16,6 +17,40 @@ const TASK_ID = "upd_sigkill_window";
|
||||
|
||||
const logger = { debug() {}, info() {}, warn() {}, error() {}, child() { return this; } };
|
||||
|
||||
// Exercise a kill after every old entry's rename, before the manifest is
|
||||
// updated. In particular the backup is still partial for the first entries.
|
||||
for (const entry of CODE_ENTRIES) {
|
||||
test(`launcher recovers a SIGKILL immediately after moving old ${entry}`, { timeout: 30_000, skip: process.platform !== "linux" }, async t => {
|
||||
const port = await availablePort();
|
||||
const fixture = buildFixture(t, port, true);
|
||||
// The Linux package need not contain the Windows launcher, but include it
|
||||
// here so the entire code-entry list has a tested interruption point.
|
||||
writeFileSync(path.join(fixture.rootDir, "start-webspeak.cmd"), "old launcher");
|
||||
const runner = spawn(process.execPath, ["--import", "tsx", RUNNER_SOURCE, path.join(fixture.dataDir, "updates", "plan.json")], {
|
||||
cwd: REPO_ROOT,
|
||||
env: { ...process.env, WEBSPEAK_TEST_SWAP_BARRIER_DIR: fixture.barrierDir, WEBSPEAK_TEST_SWAP_BARRIER_AFTER_ENTRY: entry },
|
||||
stdio: "ignore",
|
||||
});
|
||||
let app: ChildProcess | undefined;
|
||||
t.after(() => { stop(app); stop(runner); });
|
||||
await waitFor(() => existsSync(path.join(fixture.barrierDir, "swap-window-reached")), `runner never reached ${entry}`);
|
||||
stop(runner);
|
||||
await waitFor(() => !processAlive(runner.pid), "runner did not stop", 5_000);
|
||||
app = spawn(path.join(fixture.rootDir, "start-webspeak.sh"), [], {
|
||||
cwd: fixture.rootDir, env: { ...process.env, WEBSPEAK_DATA_DIR: fixture.dataDir }, stdio: "ignore",
|
||||
});
|
||||
await waitFor(() => healthVersion(port).then(version => version === "0.3.2"), `launcher failed after ${entry}`);
|
||||
assert.equal(readFileSync(path.join(fixture.rootDir, "dist", "index.js"), "utf8"), appScript());
|
||||
for (const [key, file] of Object.entries(fixture.markerFiles)) {
|
||||
if (key !== "config") assert.equal(readFileSync(file, "utf8"), `${key} preserved`);
|
||||
}
|
||||
const stale = path.join(fixture.dataDir, "updates", "backups", "aaa_stale_backup", "package.json");
|
||||
assert.equal(JSON.parse(readFileSync(stale, "utf8")).version, "0.1.0");
|
||||
stop(app);
|
||||
await waitFor(() => !processAlive(app?.pid), "app did not stop", 5_000);
|
||||
});
|
||||
}
|
||||
|
||||
const sleep = (milliseconds: number) => new Promise<void>((resolve) => setTimeout(resolve, milliseconds));
|
||||
|
||||
async function availablePort(): Promise<number> {
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { Logger } from "../logger.js";
|
||||
import { CHECKSUM_ASSET_NAME, OFFICIAL_REPOSITORY } from "./releases.js";
|
||||
import { UpdateError, UpdateService, type UpdateErrorCode, type UpdateServiceOptions } from "./update-service.js";
|
||||
import { createPackageFiles, createTarGz, sha256Hex, type TarFixtureEntry } from "./test-support.js";
|
||||
import { readUpdateState, writeUpdateState } from "./update-state.js";
|
||||
import { acquireUpdateLock, readUpdateState, writeUpdateState } from "./update-state.js";
|
||||
|
||||
const logger: Logger = { debug() {}, info() {}, warn() {}, error() {}, child() { return this; } };
|
||||
const ASSET_NAME = "webspeak-webclient-v0.4.0-linux-x64.tar.gz";
|
||||
@@ -102,6 +102,7 @@ function createService(
|
||||
architecture: "x64",
|
||||
env: {},
|
||||
isDocker: false,
|
||||
isSupervised: false,
|
||||
fetch: fakeFetch(releases, downloads),
|
||||
now: () => new Date("2026-01-01T00:00:00.000Z"),
|
||||
launchRunner: async (planPath) => { launched.push(planPath); },
|
||||
@@ -443,6 +444,37 @@ test("initialization keeps a live task but reconciles it once its process is gon
|
||||
assert.equal(restarted.getStatus().task?.errorCode, "UPDATE_INTERRUPTED");
|
||||
});
|
||||
|
||||
test("a replacement app can update again after the runner finishes its cached task", async t => {
|
||||
const fixture = createService(t, [], new Map());
|
||||
const statePath = path.join(fixture.dataDir, "updates", "state.json");
|
||||
const lockPath = path.join(fixture.dataDir, "updates", "update.lock");
|
||||
const task = {
|
||||
id: "upd_completed_runner", status: "restarting" as const, fromVersion: "0.3.1", targetVersion: "0.3.2",
|
||||
startedAt: "2026-01-01T00:00:00.000Z", updatedAt: "2026-01-01T00:00:00.000Z", finishedAt: null,
|
||||
errorCode: null, errorMessage: null, rolledBack: false, steps: [],
|
||||
};
|
||||
const release = acquireUpdateLock(lockPath, task.id);
|
||||
t.after(release);
|
||||
writeUpdateState(statePath, { schemaVersion: 1, task });
|
||||
fixture.service.initialize();
|
||||
assert.equal(fixture.service.getStatus().task?.status, "restarting");
|
||||
writeUpdateState(statePath, { schemaVersion: 1, task: { ...task, status: "succeeded", finishedAt: "2026-01-01T00:01:00.000Z" } });
|
||||
release();
|
||||
assert.equal(fixture.service.getStatus().task?.status, "succeeded");
|
||||
// It reaches release lookup instead of being rejected by a stale active task.
|
||||
await assert.rejects(fixture.service.applyUpdate("0.4.0", "0.4.0"), updateErrorCode("UPDATE_VERSION_NOT_FOUND"));
|
||||
});
|
||||
|
||||
test("supervised packages can check releases but cannot download or launch an update", async t => {
|
||||
const fixture = createService(t, [{ version: "0.4.0", assets: [] }], new Map(), { isSupervised: true });
|
||||
const checked = await fixture.service.checkForUpdates();
|
||||
assert.equal(checked.releases[0]?.blockedReason, "DEPLOYMENT_SUPERVISED");
|
||||
assert.equal(checked.releases[0]?.canApply, false);
|
||||
await assert.rejects(fixture.service.applyUpdate("0.4.0", "0.4.0"), updateErrorCode("UPDATE_NOT_SUPPORTED"));
|
||||
assert.deepEqual(fixture.launched, []);
|
||||
assert.equal(fixture.service.getStatus().task, null);
|
||||
});
|
||||
|
||||
test("initialization does not roll back a task whose lock belongs to another live process", async t => {
|
||||
const fixture = createService(t, [], new Map());
|
||||
const taskId = "upd_other_process";
|
||||
|
||||
@@ -65,6 +65,7 @@ export interface UpdateServiceOptions {
|
||||
architecture?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
isDocker?: boolean;
|
||||
isSupervised?: boolean;
|
||||
fetch?: typeof fetch;
|
||||
apiBaseUrl?: string;
|
||||
repository?: string;
|
||||
@@ -139,6 +140,7 @@ export class UpdateService {
|
||||
architecture: options.architecture,
|
||||
env: options.env,
|
||||
isDocker: options.isDocker,
|
||||
isSupervised: options.isSupervised,
|
||||
});
|
||||
this.source = new GitHubReleaseSource({
|
||||
fetch: options.fetch,
|
||||
@@ -273,7 +275,14 @@ export class UpdateService {
|
||||
if (!isNewerVersion(version, this.options.currentVersion)) {
|
||||
throw new UpdateError("UPDATE_VERSION_NOT_NEWER", "The selected version is not newer than the running version.", 409);
|
||||
}
|
||||
if (this.applying || (this.state.task && isActiveTaskStatus(this.state.task.status))) {
|
||||
if (this.applying) {
|
||||
throw new UpdateError("UPDATE_IN_PROGRESS", "Another update task is already running.", 409);
|
||||
}
|
||||
// The runner finishes after the replacement app has initialized. Its
|
||||
// terminal state on disk must replace that app's cached "restarting"
|
||||
// state before the next update; never reload during our own active apply.
|
||||
this.state = readUpdateState(this.statePath);
|
||||
if (this.state.task && isActiveTaskStatus(this.state.task.status)) {
|
||||
throw new UpdateError("UPDATE_IN_PROGRESS", "Another update task is already running.", 409);
|
||||
}
|
||||
this.applying = true;
|
||||
|
||||
@@ -293,30 +293,30 @@
|
||||
<div v-if="!canApplyUpdates" class="alert info system-notice">
|
||||
<Icon name="info" :size="16"/><span>{{ blockedUpdateText }}</span>
|
||||
</div>
|
||||
<template v-else>
|
||||
<p class="field-help">{{ tr('updateBackupHint') }}</p>
|
||||
<div>
|
||||
<p v-if="canApplyUpdates" class="field-help">{{ tr('updateBackupHint') }}</p>
|
||||
<div class="update-actions">
|
||||
<button class="secondary-button" type="button" :disabled="updateChecking" @click="checkForUpdates">
|
||||
<button class="secondary-button" type="button" data-admin-update="check" :disabled="updateChecking" @click="checkForUpdates">
|
||||
<span v-if="updateChecking" class="spinner small"></span><Icon v-else name="refresh" :size="17"/>
|
||||
{{ updateChecking ? tr('updateChecking') : tr('updateCheckAction') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="availableUpdates.length" class="update-release-list">
|
||||
<strong>{{ tr('updateSelectRelease') }}</strong>
|
||||
<p class="field-help">{{ tr('updateChecksumNotice') }}</p>
|
||||
<strong v-if="canApplyUpdates">{{ tr('updateSelectRelease') }}</strong>
|
||||
<p v-if="canApplyUpdates" class="field-help">{{ tr('updateChecksumNotice') }}</p>
|
||||
<label v-for="release in availableUpdates" :key="release.version" class="update-release-row">
|
||||
<input v-model="selectedVersion" type="radio" :value="release.version" :disabled="!release.canApply || updateApplying" />
|
||||
<input v-if="canApplyUpdates" v-model="selectedVersion" type="radio" :value="release.version" :disabled="!release.canApply || updateApplying" />
|
||||
<span><strong>v{{ release.version }}</strong> <small>{{ formatDate(release.publishedAt) }}</small></span>
|
||||
<a v-if="release.releaseUrl" :href="release.releaseUrl" target="_blank" rel="noreferrer">{{ tr('updateReleaseNotes') }}</a>
|
||||
<small v-if="!release.canApply" class="muted-label">{{ releaseBlockedText(release) }}</small>
|
||||
</label>
|
||||
<button class="primary-button" type="button" :disabled="!selectedRelease || updateApplying" @click="applySelectedUpdate">
|
||||
<button v-if="canApplyUpdates" class="primary-button" type="button" data-admin-update="apply" :disabled="!selectedRelease || updateApplying" @click="applySelectedUpdate">
|
||||
<span v-if="updateApplying" class="spinner small"></span>
|
||||
{{ updateApplying ? tr('updateApplying') : tr('updateApplyAction') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-else-if="updateChecked" class="field-help">{{ tr('updateUpToDate') }}</p>
|
||||
</template>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
@@ -349,6 +349,7 @@ function blockedReasonText(code: string | null) {
|
||||
switch (code) {
|
||||
case 'DEPLOYMENT_DOCKER': return tr('updateBlockedDocker');
|
||||
case 'DEPLOYMENT_SOURCE': return tr('updateBlockedSource');
|
||||
case 'DEPLOYMENT_SUPERVISED': return tr('updateBlockedSupervised');
|
||||
case 'PLATFORM_UNSUPPORTED': return tr('updateBlockedPlatform');
|
||||
case 'ARCH_UNSUPPORTED': return tr('updateBlockedArch');
|
||||
case 'WINDOWS_APPLY_UNVERIFIED': return tr('updateBlockedWindows');
|
||||
|
||||
@@ -21,6 +21,7 @@ const zh = {
|
||||
updateChecksumMissing: "该版本缺少 SHA256SUMS.txt,已拒绝更新。", updateAssetMissing: "该版本没有适用于当前平台和架构的发布包。",
|
||||
updateBlockedDocker: "容器内不能替换镜像。请保留 webspeak-data volume,在宿主机执行 docker compose pull && docker compose up -d;不要执行 docker compose down -v。",
|
||||
updateBlockedSource: "源码运行没有捆绑运行时,控制台无法安全切换版本。请拉取源码后自行构建(npm ci && npm run build && npm run web:build),或改用发布包/Docker Compose。",
|
||||
updateBlockedSupervised: "此实例由 systemd、PM2 等进程管理器托管,目前只能检查版本。请停止服务,手动替换发布包中的程序文件后再启动,并保留 data/、config.json 和 certs/。",
|
||||
updateBlockedPlatform: "当前平台没有官方发布包,只能检查版本。", updateBlockedArch: "当前架构没有官方发布包,只能检查版本。",
|
||||
updateBlockedWindows: "Windows 发布包的控制台更新尚未在真实 Windows 环境验证,已禁用;请下载新版发布包后手动替换。",
|
||||
updateBlockedArm64: "Linux arm64 发布包的控制台更新尚未在真实硬件实测,已禁用;请下载新版发布包后手动替换。",
|
||||
@@ -70,6 +71,7 @@ const en = {
|
||||
updateChecksumMissing: "This release has no SHA256SUMS.txt; the update is refused.", updateAssetMissing: "This release has no package for the current platform and architecture.",
|
||||
updateBlockedDocker: "An image cannot be replaced from inside the container. Keep the webspeak-data volume and run docker compose pull && docker compose up -d on the host. Never run docker compose down -v.",
|
||||
updateBlockedSource: "Source installs have no bundled runtime, so the console cannot switch versions safely. Pull the source and rebuild (npm ci && npm run build && npm run web:build), or use a release package/Docker Compose.",
|
||||
updateBlockedSupervised: "This instance runs under a process manager such as systemd or PM2; only version checks are available. Stop the service, replace the package's application files manually, then start it again. Preserve data/, config.json and certs/.",
|
||||
updateBlockedPlatform: "No official package exists for this platform; only version checks are available.", updateBlockedArch: "No official package exists for this architecture; only version checks are available.",
|
||||
updateBlockedWindows: "Console updates for Windows release packages are disabled until they are verified on a real Windows install. Download the new package and replace it manually.",
|
||||
updateBlockedArm64: "Console updates for Linux arm64 release packages are disabled until they are verified on real hardware. Download the new package and replace it manually.",
|
||||
@@ -118,6 +120,7 @@ const de = {
|
||||
updateChecksumMissing: "Diesem Release fehlt SHA256SUMS.txt; das Update wird abgelehnt.", updateAssetMissing: "Dieses Release hat kein Paket für Plattform und Architektur.",
|
||||
updateBlockedDocker: "Ein Image kann nicht im Container ersetzt werden. Das Volume webspeak-data behalten und auf dem Host docker compose pull && docker compose up -d ausführen. Niemals docker compose down -v verwenden.",
|
||||
updateBlockedSource: "Quellinstallationen haben keine mitgelieferte Laufzeit; die Konsole kann Versionen nicht sicher wechseln. Quellen aktualisieren und neu bauen (npm ci && npm run build && npm run web:build) oder Release-Paket/Docker Compose verwenden.",
|
||||
updateBlockedSupervised: "Diese Instanz wird etwa von systemd oder PM2 verwaltet; nur Versionsprüfungen sind verfügbar. Dienst stoppen, Programmdateien manuell ersetzen und wieder starten. data/, config.json und certs/ behalten.",
|
||||
updateBlockedPlatform: "Für diese Plattform gibt es kein offizielles Paket; nur Versionsprüfungen sind möglich.", updateBlockedArch: "Für diese Architektur gibt es kein offizielles Paket; nur Versionsprüfungen sind möglich.",
|
||||
updateBlockedWindows: "Konsolen-Updates für Windows-Release-Pakete sind deaktiviert, bis sie auf einer echten Windows-Installation geprüft wurden. Laden Sie das neue Paket herunter und ersetzen Sie es manuell.",
|
||||
updateBlockedArm64: "Konsolen-Updates für Linux-arm64-Release-Pakete sind deaktiviert, bis sie auf echter Hardware geprüft wurden. Laden Sie das neue Paket herunter und ersetzen Sie es manuell.",
|
||||
@@ -166,6 +169,7 @@ const ru = {
|
||||
updateChecksumMissing: "В релизе нет SHA256SUMS.txt; обновление отклонено.", updateAssetMissing: "В релизе нет пакета для текущей платформы и архитектуры.",
|
||||
updateBlockedDocker: "Образ нельзя заменить изнутри контейнера. Сохраните том webspeak-data и выполните на хосте docker compose pull && docker compose up -d. Никогда не запускайте docker compose down -v.",
|
||||
updateBlockedSource: "В установке из исходников нет встроенной среды выполнения, поэтому консоль не может безопасно сменить версию. Обновите исходники и пересоберите (npm ci && npm run build && npm run web:build) или используйте пакет релиза/Docker Compose.",
|
||||
updateBlockedSupervised: "Экземпляр управляется systemd, PM2 или другим менеджером процессов; доступна только проверка версий. Остановите службу, вручную замените файлы программы и запустите её снова. Сохраните data/, config.json и certs/.",
|
||||
updateBlockedPlatform: "Для этой платформы нет официального пакета; доступна только проверка версий.", updateBlockedArch: "Для этой архитектуры нет официального пакета; доступна только проверка версий.",
|
||||
updateBlockedWindows: "Обновление из консоли для релизных пакетов Windows отключено до проверки на реальной установке Windows. Скачайте новый пакет и замените его вручную.",
|
||||
updateBlockedArm64: "Обновление из консоли для релизных пакетов Linux arm64 отключено до проверки на реальном оборудовании. Скачайте новый пакет и замените его вручную.",
|
||||
@@ -214,6 +218,7 @@ const ja = {
|
||||
updateChecksumMissing: "このリリースには SHA256SUMS.txt がないため、更新を拒否しました。", updateAssetMissing: "このリリースには現在のプラットフォームとアーキテクチャ向けのパッケージがありません。",
|
||||
updateBlockedDocker: "コンテナ内からイメージは置き換えられません。webspeak-data ボリュームを保持し、ホストで docker compose pull && docker compose up -d を実行してください。docker compose down -v は実行しないでください。",
|
||||
updateBlockedSource: "ソース実行には同梱ランタイムがないため、安全にバージョンを切り替えられません。ソースを取得して再ビルドする(npm ci && npm run build && npm run web:build)か、リリースパッケージ/Docker Compose を使用してください。",
|
||||
updateBlockedSupervised: "このインスタンスは systemd や PM2 などで管理されているため、バージョン確認のみ可能です。サービスを停止し、プログラムファイルを手動で置き換えて再起動してください。data/、config.json、certs/ は保持してください。",
|
||||
updateBlockedPlatform: "このプラットフォーム向けの公式パッケージがないため、バージョン確認のみ可能です。", updateBlockedArch: "このアーキテクチャ向けの公式パッケージがないため、バージョン確認のみ可能です。",
|
||||
updateBlockedWindows: "Windows リリースパッケージのコンソール更新は、実際の Windows 環境で検証するまで無効です。新しいパッケージをダウンロードして手動で置き換えてください。",
|
||||
updateBlockedArm64: "Linux arm64 リリースパッケージのコンソール更新は、実機で検証するまで無効です。新しいパッケージをダウンロードして手動で置き換えてください。",
|
||||
|
||||
@@ -725,6 +725,35 @@ test("settings and operations render explicit localized sections with valid deep
|
||||
}
|
||||
});
|
||||
|
||||
test("check-only deployments retain release checks and notes without install controls", async () => {
|
||||
const { createSSRApp } = await import("vue");
|
||||
const { renderToString } = await import("vue/server-renderer");
|
||||
const { default: Operations } = await vite.ssrLoadModule("/src/components/admin/AdminOperations.vue");
|
||||
await mount("/admin/operations?section=maintenance");
|
||||
const model = reactive(state.adminOperations);
|
||||
for (const [mode, reasonCode] of [["source", "DEPLOYMENT_SOURCE"], ["docker", "DEPLOYMENT_DOCKER"],
|
||||
["release-package", "WINDOWS_APPLY_UNVERIFIED"], ["release-package", "LINUX_ARM64_APPLY_UNVERIFIED"], ["release-package", "DEPLOYMENT_SUPERVISED"]]) {
|
||||
model.operations.update.deployment = { mode, platform: "linux", architecture: "x64", applyAllowed: false, reasonCode, upgradePath: "release-package" };
|
||||
let checked = false;
|
||||
handler = path => {
|
||||
assert.equal(path, "/update/check"); checked = true;
|
||||
return Promise.resolve(json({ currentVersion: "0.3.2", releases: [{ version: "0.4.0", canApply: false, blockedReason: reasonCode,
|
||||
tag: "v0.4.0", assetName: "webspeak-webclient-v0.4.0-linux-x64.tar.gz", assetSize: 100,
|
||||
assetAvailable: true, hasChecksums: true, digest: null,
|
||||
publishedAt: "2026-11-25T00:00:00.000Z", releaseUrl: "https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.4.0" }] }));
|
||||
};
|
||||
await model.checkForUpdates();
|
||||
assert.equal(checked, true);
|
||||
assert.equal(state.errorMessage, "");
|
||||
const html = await renderToString(createSSRApp(Operations, { model: state.adminOperations, i18n: state.i18n, initialSection: "maintenance" }));
|
||||
assert.ok(html.includes(state.i18n.tr("updateCheckAction")), reasonCode);
|
||||
assert.ok(html.includes("/releases/tag/v0.4.0"), reasonCode);
|
||||
assert.ok(html.includes('data-admin-update="check"'), reasonCode);
|
||||
assert.ok(!html.includes('data-admin-update="apply"'), reasonCode);
|
||||
if (reasonCode === "DEPLOYMENT_SUPERVISED") assert.ok(html.includes(state.i18n.tr("updateBlockedSupervised")));
|
||||
}
|
||||
});
|
||||
|
||||
test("update error codes resolve to their dedicated five-language labels", async () => {
|
||||
const { adminOrganizationCopy } = await vite.ssrLoadModule("/src/i18n/admin-organization.ts");
|
||||
await mount("/admin/server");
|
||||
|
||||
Reference in new issue
Block a user