# Always remove linked worktree workspaces before archive cleanup \(\#53672\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 15dce9de1c2be7670254bbc5008332b435fb7327

Requested commit: 15dce9de1c2be7670254bbc5008332b435fb7327

Commit: 15dce9de1c2be7670254bbc5008332b435fb7327

Tree: abe286972518415fb21b90db58f37ea85c97eb76

Author: Richard Feldman

Committer: GitHub

## Message

```
Always remove linked worktree workspaces before archive cleanup (#53672)

When archiving a thread's last reference to a linked worktree, the
worktree workspace must be removed from the MultiWorkspace before the
background cleanup task runs `git worktree remove`. Previously, only the
workspace found via exact PathList match on the thread's `folder_paths`
was removed. This missed cases where the workspace's root paths diverged
from the thread's `folder_paths` (e.g. after folders were added/removed
from the workspace).

Now we also scan `roots_to_archive` for any linked worktree workspaces
that contain the worktree being archived and include them in the removal
set. This ensures all editors are dropped, releasing their
`Entity<Worktree>` references (held through `File` structs in buffers),
so `wait_for_worktree_release` completes and `git worktree remove` can
proceed.

Release Notes:

- Fixed some linked worktree directories not always being cleaned up
from disk when archiving a thread.
```

## Parents

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

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