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): revalidate snapshot target identity after publish rename

Yuewei-LLe84a9de66e7d
diff --git a/apps/desktop/src/main/cindy-brain/ghostSnapshotWorkerProcess.ts b/apps/desktop/src/main/cindy-brain/ghostSnapshotWorkerProcess.ts
index 3077c6b433..b8b9c456fe 100644
--- a/apps/desktop/src/main/cindy-brain/ghostSnapshotWorkerProcess.ts
+++ b/apps/desktop/src/main/cindy-brain/ghostSnapshotWorkerProcess.ts
@@ -169,6 +169,14 @@ export async function runGhostSnapshotWorkerRequest(
const tempBeforeRename = await classifyGhostDirEntry(tempPath);
if (tempBeforeRename !== 'directory') throw new Error('snapshot temp directory was replaced before rename');
await fs.promises.rename(tempPath, targetPath);
+ const targetEntryKind = await classifyGhostDirEntry(targetPath);
+ if (targetEntryKind !== 'directory') {
+ if (await verifyParent(request.expectedParent, workingDir).then(() => true, () => false) &&
+ await verifyDirectory(workingDir, parts[0]).then(() => true, () => false)) {
+ await fs.promises.rm(targetPath, { recursive: true, force: true }).catch(() => undefined);
+ }
+ throw new Error('snapshot target is not a real directory after publish');
+ }
await verifyParent(request.expectedParent, workingDir);
await verifyDirectory(workingDir, parts[0]);
if (!await matches(request.receipt, targetPath)) {