fix(test): stabilize core runtime infra shard · openclaw/openclaw@8e5fcff
vincentkoc
·
2026-04-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -12,8 +12,17 @@ import {
|
12 | 12 | |
13 | 13 | async function writeSecureFile(filePath: string, content: string, mode = 0o600): Promise<void> { |
14 | 14 | await fs.mkdir(path.dirname(filePath), { recursive: true }); |
15 | | -await fs.writeFile(filePath, content, "utf8"); |
16 | | -await fs.chmod(filePath, mode); |
| 15 | +const tempPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random() |
| 16 | + .toString(16) |
| 17 | + .slice(2)}`; |
| 18 | +try { |
| 19 | +await fs.writeFile(tempPath, content, "utf8"); |
| 20 | +await fs.chmod(tempPath, mode); |
| 21 | +await fs.rename(tempPath, filePath); |
| 22 | +} catch (err) { |
| 23 | +await fs.rm(tempPath, { force: true }).catch(() => {}); |
| 24 | +throw err; |
| 25 | +} |
17 | 26 | } |
18 | 27 | |
19 | 28 | describe("secret ref resolver", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。