Skip to content

Commit 89064c3

Browse files
authored
fix(opencode): cleanup orphaned worktree directories (#12399)
1 parent fde0b39 commit 89064c3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/opencode/src/worktree/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,13 @@ export namespace Worktree {
411411
if (key === directory) return item
412412
}
413413
})()
414+
414415
if (!entry?.path) {
415-
throw new RemoveFailedError({ message: "Worktree not found" })
416+
const directoryExists = await exists(directory)
417+
if (directoryExists) {
418+
await fs.rm(directory, { recursive: true, force: true })
419+
}
420+
return true
416421
}
417422

418423
const removed = await $`git worktree remove --force ${entry.path}`.quiet().nothrow().cwd(Instance.worktree)

0 commit comments

Comments
 (0)