From 0d31c8c1c8773863be2862d26825149cf85d9b34 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 6 Jan 2023 10:41:11 -0700 Subject: [PATCH] Only share worktrees when `UpdateProject` succeeded --- crates/project/src/project.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index f88956ab5e..0f750e3255 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1026,19 +1026,21 @@ impl Project { let Some(this) = this.upgrade(&cx) else { break }; let worktrees = this.read_with(&cx, |this, cx| this.worktrees(cx).collect::>()); - this.read_with(&cx, |this, cx| { - this.client.request(proto::UpdateProject { - project_id, - worktrees: this.worktree_metadata_protos(cx), + let update_project = this + .read_with(&cx, |this, cx| { + this.client.request(proto::UpdateProject { + project_id, + worktrees: this.worktree_metadata_protos(cx), + }) }) - }) - .await - .log_err(); - for worktree in worktrees { - worktree.update(&mut cx, |worktree, cx| { - let worktree = &mut worktree.as_local_mut().unwrap(); - worktree.share(project_id, cx).detach_and_log_err(cx) - }); + .await; + if update_project.is_ok() { + for worktree in worktrees { + worktree.update(&mut cx, |worktree, cx| { + let worktree = &mut worktree.as_local_mut().unwrap(); + worktree.share(project_id, cx).detach_and_log_err(cx) + }); + } } for tx in txs.drain(..) {