惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
腾讯CDC
J
Java Code Geeks
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
云风的 BLOG
云风的 BLOG
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
雷峰网
雷峰网
B
Blog RSS Feed
博客园_首页
量子位
F
Fortinet All Blogs
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
harden update restart script creation [AI] (#84088) · ope...
pgondhi987 · 2026-05-19 · via Recent Commits to openclaw:main

@@ -34,6 +34,11 @@ describe("restart-helper", () => {

3434

throw error;

3535

}

3636

});

37+

await fs.rmdir(path.dirname(scriptPath)).catch((error: unknown) => {

38+

if ((error as NodeJS.ErrnoException).code !== "ENOENT") {

39+

throw error;

40+

}

41+

});

3742

}

38433944

async function makeTempDir(prefix: string) {

@@ -135,9 +140,63 @@ exit 0

135140

expect(content).toContain("systemctl --user restart 'openclaw-gateway.service'");

136141

// Script should self-cleanup

137142

expect(content).toContain('rm -f "$0"');

143+

expect(content).toContain('rmdir "$script_dir" 2>/dev/null || true');

138144

await cleanupScript(scriptPath);

139145

});

140146147+

it("creates restart scripts in a private temp directory with exclusive creation", async () => {

148+

Object.defineProperty(process, "platform", { value: "linux" });

149+

const timestamp = 1_727_201_234_567;

150+

const oldCandidatePath = path.join(os.tmpdir(), `openclaw-restart-${timestamp}.sh`);

151+

const victimDir = await makeTempDir("openclaw-restart-helper-victim-");

152+

const victimPath = path.join(victimDir, "restart.sh");

153+

await fs.rm(oldCandidatePath, { force: true });

154+

await fs.writeFile(victimPath, "preexisting script\n", "utf-8");

155+156+

let candidateIsSymlink = false;

157+

try {

158+

await fs.symlink(victimPath, oldCandidatePath);

159+

candidateIsSymlink = true;

160+

} catch {

161+

await fs.writeFile(oldCandidatePath, "preexisting script\n", { flag: "wx" });

162+

}

163+164+

const dateSpy = vi.spyOn(Date, "now").mockReturnValue(timestamp);

165+

const writeFileSpy = vi.spyOn(fs, "writeFile");

166+167+

try {

168+

const { scriptPath } = await prepareAndReadScript({

169+

OPENCLAW_PROFILE: "default",

170+

});

171+

const scriptDir = path.dirname(scriptPath);

172+

const relativeScriptDir = path.relative(os.tmpdir(), scriptDir);

173+174+

expect(scriptPath).not.toBe(oldCandidatePath);

175+

expect(scriptDir).not.toBe(os.tmpdir());

176+

expect(relativeScriptDir).not.toBe("");

177+

expect(relativeScriptDir.startsWith("..")).toBe(false);

178+

expect(path.isAbsolute(relativeScriptDir)).toBe(false);

179+

expect(path.basename(scriptDir)).toMatch(/^openclaw-restart-/);

180+

expect(writeFileSpy).toHaveBeenLastCalledWith(

181+

scriptPath,

182+

expect.any(String),

183+

expect.objectContaining({ flag: "wx", mode: 0o755 }),

184+

);

185+

await expect(fs.readFile(victimPath, "utf-8")).resolves.toBe("preexisting script\n");

186+

if (!candidateIsSymlink) {

187+

await expect(fs.readFile(oldCandidatePath, "utf-8")).resolves.toBe(

188+

"preexisting script\n",

189+

);

190+

}

191+

await cleanupScript(scriptPath);

192+

} finally {

193+

dateSpy.mockRestore();

194+

writeFileSpy.mockRestore();

195+

await fs.rm(oldCandidatePath, { force: true });

196+

await fs.rm(victimDir, { recursive: true, force: true });

197+

}

198+

});

199+141200

it("uses OPENCLAW_SYSTEMD_UNIT override for systemd scripts", async () => {

142201

Object.defineProperty(process, "platform", { value: "linux" });

143202

const { scriptPath, content } = await prepareAndReadScript({

@@ -203,6 +262,7 @@ exit 1

203262

expect(content).toContain("launchctl bootstrap 'gui/501'");

204263

expect(content).toContain("Bootstrap loads RunAtLoad agents");

205264

expect(content).toContain('rm -f "$0"');

265+

expect(content).toContain('rmdir "$script_dir" 2>/dev/null || true');

206266

await cleanupScript(scriptPath);

207267

});

208268

@@ -379,6 +439,7 @@ exit 0

379439

expect(content).toContain("openclaw restart launched startup fallback");

380440

expectWindowsRestartWaitOrdering(content);

381441

expect(content).toContain('del "%~f0" >nul 2>&1');

442+

expect(content).toContain('rmdir "%OPENCLAW_RESTART_SCRIPT_DIR%" >nul 2>&1');

382443

await cleanupScript(scriptPath);

383444

});

384445