The delete operation in hashline-edit.ts wrapped both access() and unlink() in a single try/catch. If access succeeded but unlink failed (e.g., permissions), the error was silently swallowed and "Deleted" was falsely reported. Now access and unlink have separate error handling: access failures indicate the file doesn't exist, while unlink failures propagate to the caller. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
41418194e9
commit
f7b3144291
1 changed files with 6 additions and 3 deletions
|
|
@ -177,15 +177,18 @@ export function createHashlineEditTool(cwd: string, options?: HashlineEditToolOp
|
|||
try {
|
||||
// Handle delete
|
||||
if (deleteFile) {
|
||||
let fileExists = true;
|
||||
try {
|
||||
await ops.access(absolutePath);
|
||||
await ops.unlink(absolutePath);
|
||||
} catch {
|
||||
// File doesn't exist, that's fine for delete
|
||||
fileExists = false;
|
||||
}
|
||||
if (fileExists) {
|
||||
await ops.unlink(absolutePath);
|
||||
}
|
||||
if (signal) signal.removeEventListener("abort", onAbort);
|
||||
resolve({
|
||||
content: [{ type: "text", text: `Deleted ${path}` }],
|
||||
content: [{ type: "text", text: fileExists ? `Deleted ${path}` : `File not found, nothing to delete: ${path}` }],
|
||||
details: { diff: "" },
|
||||
});
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue