fix: separate access/unlink error handling in delete path (#219) (#222)

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:
TÂCHES 2026-03-13 12:27:28 -06:00 committed by GitHub
parent 41418194e9
commit f7b3144291

View file

@ -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;