fix: make agent snapshots writable
This commit is contained in:
1 parent
087b19e705
commit
b6239fc458
4 files changed
+30
No files matched your search
@@ -345,9 +345,26 @@ export async function createRepositorySnapshot(sourceWorktree: string): Promise<
|
||||
return !(await fs.lstat(source)).isSymbolicLink();
|
||||
}
|
||||
});
|
||||
await makeSnapshotWritableForContainer(snapshot);
|
||||
return snapshot;
|
||||
} catch (error) {
|
||||
await fs.rm(snapshot, { recursive: true, force: true });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function makeSnapshotWritableForContainer(directory: string): Promise<void> {
|
||||
await fs.chmod(directory, 0o777);
|
||||
const entries = await fs.readdir(directory, { withFileTypes: true });
|
||||
await Promise.all(entries.map(async (entry) => {
|
||||
const target = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
await makeSnapshotWritableForContainer(target);
|
||||
return;
|
||||
}
|
||||
if (entry.isFile()) {
|
||||
const stat = await fs.stat(target);
|
||||
await fs.chmod(target, stat.mode & 0o111 ? 0o777 : 0o666);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -38,7 +38,9 @@ export async function writeKnowledgeScratch(snapshot: string, content: string):
|
||||
validateRepositoryKnowledge(content);
|
||||
const target = path.join(snapshot, REPOSITORY_KNOWLEDGE_SCRATCH_PATH);
|
||||
await fs.mkdir(path.dirname(target), { recursive: true });
|
||||
await fs.chmod(path.dirname(target), 0o777);
|
||||
await fs.writeFile(target, normalizeKnowledge(content), "utf8");
|
||||
await fs.chmod(target, 0o666);
|
||||
}
|
||||
|
||||
export async function readKnowledgeScratch(snapshot: string): Promise<string> {
|
||||
|
||||
Reference in new issue
Block a user