1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-10-01 16:54:08 +02:00

fix cleaning up worktree if there are no worktrees

This commit is contained in:
Robin Appelman 2026-08-17 17:54:27 +02:00
commit c5c2bdbf50

View file

@ -105,7 +105,11 @@ async fn creates_worktrees_for_instance(
async fn remove_worktrees_for_instance(config: &HazeConfig, id: &str) -> Result<()> {
let worktree_dir = config.worktree_dir.join(id);
remove_worktree(&worktree_dir)?;
if !worktree_dir.exists() {
return Ok(());
}
remove_worktree(&worktree_dir).wrap_err("Failed to remove worktree for server")?;
for app_dir in &config.app_directories {
let Some(dir_name) = app_dir.file_name() else {
@ -115,7 +119,8 @@ async fn remove_worktrees_for_instance(config: &HazeConfig, id: &str) -> Result<
continue;
};
for app_worktree in app_worktrees.flatten() {
remove_worktree(app_worktree.path())?;
remove_worktree(app_worktree.path())
.wrap_err_with(|| format!("Failed to remove worktree for {dir_name}"))?;
}
}