mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 01:33:29 +00:00
fix(tools): land #31015 from @haosenwang1018
Co-authored-by: haosenwang1018 <1293965075@qq.com>
This commit is contained in:
@@ -843,7 +843,17 @@ function createHostEditOperations(root: string, options?: { workspaceOnly?: bool
|
||||
});
|
||||
},
|
||||
access: async (absolutePath: string) => {
|
||||
const relative = toRelativePathInRoot(root, absolutePath);
|
||||
let relative: string;
|
||||
try {
|
||||
relative = toRelativePathInRoot(root, absolutePath);
|
||||
} catch {
|
||||
// Path escapes workspace root. Don't throw here – the upstream
|
||||
// library replaces any `access` error with a misleading "File not
|
||||
// found" message. By returning silently the subsequent `readFile`
|
||||
// call will throw the same "Path escapes workspace root" error
|
||||
// through a code-path that propagates the original message.
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const opened = await openFileWithinRoot({
|
||||
rootDir: root,
|
||||
@@ -855,7 +865,9 @@ function createHostEditOperations(root: string, options?: { workspaceOnly?: bool
|
||||
throw createFsAccessError("ENOENT", absolutePath);
|
||||
}
|
||||
if (error instanceof SafeOpenError && error.code === "outside-workspace") {
|
||||
throw createFsAccessError("EACCES", absolutePath);
|
||||
// Don't throw here – see the comment above about the upstream
|
||||
// library swallowing access errors as "File not found".
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user