mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 21:24:31 +00:00
refactor: unify boundary-safe reads for bootstrap and includes
This commit is contained in:
@@ -74,6 +74,34 @@ describe("workspace bootstrap file caching", () => {
|
||||
expectAgentsContent(agentsFile2, content2);
|
||||
});
|
||||
|
||||
it("invalidates cache when inode changes with same mtime", async () => {
|
||||
if (process.platform === "win32") {
|
||||
return;
|
||||
}
|
||||
const content1 = "# old-content";
|
||||
const content2 = "# new-content";
|
||||
const filePath = path.join(workspaceDir, DEFAULT_AGENTS_FILENAME);
|
||||
const tempPath = path.join(workspaceDir, ".AGENTS.tmp");
|
||||
|
||||
await writeWorkspaceFile({
|
||||
dir: workspaceDir,
|
||||
name: DEFAULT_AGENTS_FILENAME,
|
||||
content: content1,
|
||||
});
|
||||
const originalStat = await fs.stat(filePath);
|
||||
|
||||
const agentsFile1 = await loadAgentsFile(workspaceDir);
|
||||
expectAgentsContent(agentsFile1, content1);
|
||||
|
||||
await fs.writeFile(tempPath, content2, "utf-8");
|
||||
await fs.utimes(tempPath, originalStat.atime, originalStat.mtime);
|
||||
await fs.rename(tempPath, filePath);
|
||||
await fs.utimes(filePath, originalStat.atime, originalStat.mtime);
|
||||
|
||||
const agentsFile2 = await loadAgentsFile(workspaceDir);
|
||||
expectAgentsContent(agentsFile2, content2);
|
||||
});
|
||||
|
||||
it("handles file deletion gracefully", async () => {
|
||||
const content = "# Some content";
|
||||
const filePath = path.join(workspaceDir, DEFAULT_AGENTS_FILENAME);
|
||||
|
||||
Reference in New Issue
Block a user