# Use Fs abstraction for worktree directory removal \(\#54088\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/bb660d25ed0f61847c7aaca1f23d48db6ced5239)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: bb660d25ed0f61847c7aaca1f23d48db6ced5239

Requested commit: bb660d25ed0f61847c7aaca1f23d48db6ced5239

Commit: bb660d25ed0f61847c7aaca1f23d48db6ced5239

Tree: 74d260981a439a975e6cfcf89c90070ad33062ae

Author: Richard Feldman

Committer: GitHub

## Message

```
Use Fs abstraction for worktree directory removal (#54088)

Replace `std::fs::remove_dir_all` with the `Fs` trait's `remove_dir`
method in `remove_root_after_worktree_removal`. This makes the code
testable with `FakeFs` and consistent with the rest of the codebase.

- Add `Arc<dyn Fs>` parameter to `remove_root` and its internal helper
- Use `RemoveOptions { recursive, ignore_if_not_exists }` which handles
both the recursive deletion and NotFound cases cleanly
- Pass `fs` from workspace `AppState` through the sidebar call chain
- Add test verifying error propagation and rollback when `remove_dir`
fails
- Remove tests that were testing raw `std::fs::remove_dir_all` patterns

Release Notes:

- N/A
```

## Parents

- [fdd81d015f1359d33026ad68c3f5d085919e1864](https://git.cafe/gitcafe/zed/commit/fdd81d015f1359d33026ad68c3f5d085919e1864?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/bb660d25ed0f61847c7aaca1f23d48db6ced5239?format=markdown)
