fix(infra): support non-durable text writes · openclaw/openclaw@11a0382
vincentkoc
·
2026-05-07
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -96,6 +96,18 @@ describe("json file helpers", () => {
|
96 | 96 | }); |
97 | 97 | }); |
98 | 98 | |
| 99 | +it("can skip durable fsync work for hot state writes", async () => { |
| 100 | +await withTempDir({ prefix: "openclaw-json-files-" }, async (base) => { |
| 101 | +const filePath = path.join(base, "state.json"); |
| 102 | +const openSpy = vi.spyOn(fs, "open"); |
| 103 | + |
| 104 | +await writeTextAtomic(filePath, "new", { durable: false }); |
| 105 | + |
| 106 | +expect(openSpy).not.toHaveBeenCalled(); |
| 107 | +await expect(fs.readFile(filePath, "utf8")).resolves.toBe("new"); |
| 108 | +}); |
| 109 | +}); |
| 110 | + |
99 | 111 | it("preserves text when Windows rename reports EPERM", async () => { |
100 | 112 | await withTempDir({ prefix: "openclaw-json-files-" }, async (base) => { |
101 | 113 | const filePath = path.join(base, "state.json"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。