Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): reject unstable plugin leaf paths

Yuewei-LL525c16927854
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostContentTree.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostContentTree.test.ts
index 4d9c5ea5dc..d67a00be78 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostContentTree.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostContentTree.test.ts
@@ -297,8 +297,15 @@ describe('hashGhostContentFiles', () => {
) => {
const handle = await realOpen(...args);
if (path.resolve(String(args[0])) !== path.resolve(file)) return handle;
+ let pinnedHandleStat: fs.BigIntStats | undefined;
return new Proxy(handle, {
get(target, key) {
+ if (key === 'stat') {
+ return async () => {
+ pinnedHandleStat ??= await handle.stat({ bigint: true });
+ return pinnedHandleStat;
+ };
+ }
if (key === 'createReadStream') {
return () => Readable.from((async function*() {
const first = Buffer.alloc(splitAt);
@@ -373,7 +380,7 @@ describe('hashGhostContentFiles', () => {
try {
await expect(
hashGhostContentFiles(root, tree.files, tree.rootIdentity),
- ).rejects.toThrow(/entry path changed while reading/);
+ ).rejects.toThrow(/entry (?:changed|path changed) while reading/);
} finally {
openSpy.mockRestore();
}
diff --git a/apps/desktop/src/main/cindy-brain/ghostContentTree.ts b/apps/desktop/src/main/cindy-brain/ghostContentTree.ts
index 4d22a6590e..64206f96d4 100644
--- a/apps/desktop/src/main/cindy-brain/ghostContentTree.ts
+++ b/apps/desktop/src/main/cindy-brain/ghostContentTree.ts
@@ -391,6 +391,9 @@ export async function hashGhostContentFiles(
) {
throw new Error(`ghost content entry path changed while reading: ${relativePath}`);
}
+ if (!sameStableFileState(handleStat, afterReadPathStat)) {
+ throw new Error(`ghost content entry changed while reading: ${relativePath}`);
+ }
assertGhostContentAncestorIdentities(
ancestorIdentities,
await captureGhostContentAncestorIdentities(rootIdentity.realPath, relativePath),