From e03966e4f44c13fa018a9e61031a786bc095cb34 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 1 Apr 2026 11:02:29 -0400 Subject: [PATCH] Handle per-path restoration failures gracefully in maybe_restore_git_worktrees Individual path failures now log the error and fall back to the original path instead of aborting the entire loop. Cleanup only runs after successful restoration. The thread always activates at the end with whatever paths were successfully restored. --- crates/sidebar/src/sidebar.rs | 42 ++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index db8b2276be282ecb70c380b95463477f98faeee9..1c532d03b569dd35ed858a9d70b5745ce47064ac 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -2263,25 +2263,47 @@ impl Sidebar { for path in &paths { let path_str = path.to_string_lossy().to_string(); - let archived_worktree = store + let archived_worktree = match store .update(cx, |store, cx| { store.get_archived_worktree_by_path(path_str, cx) }) - .await?; + .await + { + Ok(row) => row, + Err(err) => { + log::error!( + "Failed to query archived worktree for {}: {err}", + path.display() + ); + final_paths.push(path.clone()); + continue; + } + }; match archived_worktree { None => { - // No archived worktree record — keep the original path. final_paths.push(path.clone()); } Some(row) => { - // Restore from WIP commit. - let restored_path = - Self::restore_archived_worktree(&row, &workspaces, cx).await?; - final_paths.push(restored_path); - - // Clean up the archived worktree record and ref. - Self::maybe_cleanup_archived_worktree(&row, &store, &workspaces, cx).await; + match Self::restore_archived_worktree(&row, &workspaces, cx).await { + Ok(restored_path) => { + final_paths.push(restored_path); + Self::maybe_cleanup_archived_worktree( + &row, + &store, + &workspaces, + cx, + ) + .await; + } + Err(err) => { + log::error!( + "Failed to restore archived worktree for {}: {err}", + path.display() + ); + final_paths.push(path.clone()); + } + } } } }