mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:47:39 +00:00
Update: harden control UI asset handling in update flow (#10146)
* Update: harden control UI asset handling in update flow * fix: harden update doctor entrypoint guard (#10146) (thanks @gumadeiras)
This commit is contained in:
committed by
GitHub
parent
50e687d17d
commit
c75275f109
@@ -5,6 +5,32 @@ import { runCommandWithTimeout } from "../process/exec.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { resolveOpenClawPackageRoot, resolveOpenClawPackageRootSync } from "./openclaw-root.js";
|
||||
|
||||
const CONTROL_UI_DIST_PATH_SEGMENTS = ["dist", "control-ui", "index.html"] as const;
|
||||
|
||||
export function resolveControlUiDistIndexPathForRoot(root: string): string {
|
||||
return path.join(root, ...CONTROL_UI_DIST_PATH_SEGMENTS);
|
||||
}
|
||||
|
||||
export type ControlUiDistIndexHealth = {
|
||||
indexPath: string | null;
|
||||
exists: boolean;
|
||||
};
|
||||
|
||||
export async function resolveControlUiDistIndexHealth(
|
||||
opts: {
|
||||
root?: string;
|
||||
argv1?: string;
|
||||
} = {},
|
||||
): Promise<ControlUiDistIndexHealth> {
|
||||
const indexPath = opts.root
|
||||
? resolveControlUiDistIndexPathForRoot(opts.root)
|
||||
: await resolveControlUiDistIndexPath(opts.argv1 ?? process.argv[1]);
|
||||
return {
|
||||
indexPath,
|
||||
exists: Boolean(indexPath && fs.existsSync(indexPath)),
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveControlUiRepoRoot(
|
||||
argv1: string | undefined = process.argv[1],
|
||||
): string | null {
|
||||
@@ -190,8 +216,9 @@ export async function ensureControlUiAssetsBuilt(
|
||||
runtime: RuntimeEnv = defaultRuntime,
|
||||
opts?: { timeoutMs?: number },
|
||||
): Promise<EnsureControlUiAssetsResult> {
|
||||
const indexFromDist = await resolveControlUiDistIndexPath(process.argv[1]);
|
||||
if (indexFromDist && fs.existsSync(indexFromDist)) {
|
||||
const health = await resolveControlUiDistIndexHealth({ argv1: process.argv[1] });
|
||||
const indexFromDist = health.indexPath;
|
||||
if (health.exists) {
|
||||
return { ok: true, built: false };
|
||||
}
|
||||
|
||||
@@ -207,7 +234,7 @@ export async function ensureControlUiAssetsBuilt(
|
||||
};
|
||||
}
|
||||
|
||||
const indexPath = path.join(repoRoot, "dist", "control-ui", "index.html");
|
||||
const indexPath = resolveControlUiDistIndexPathForRoot(repoRoot);
|
||||
if (fs.existsSync(indexPath)) {
|
||||
return { ok: true, built: false };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user