Only share worktrees when UpdateProject succeeded

This commit is contained in:
Antonio Scandurra 2023-01-06 10:41:11 -07:00
parent 8c5a0ca3a4
commit 0d31c8c1c8

View file

@ -1026,20 +1026,22 @@ impl Project {
let Some(this) = this.upgrade(&cx) else { break }; let Some(this) = this.upgrade(&cx) else { break };
let worktrees = let worktrees =
this.read_with(&cx, |this, cx| this.worktrees(cx).collect::<Vec<_>>()); this.read_with(&cx, |this, cx| this.worktrees(cx).collect::<Vec<_>>());
this.read_with(&cx, |this, cx| { let update_project = this
.read_with(&cx, |this, cx| {
this.client.request(proto::UpdateProject { this.client.request(proto::UpdateProject {
project_id, project_id,
worktrees: this.worktree_metadata_protos(cx), worktrees: this.worktree_metadata_protos(cx),
}) })
}) })
.await .await;
.log_err(); if update_project.is_ok() {
for worktree in worktrees { for worktree in worktrees {
worktree.update(&mut cx, |worktree, cx| { worktree.update(&mut cx, |worktree, cx| {
let worktree = &mut worktree.as_local_mut().unwrap(); let worktree = &mut worktree.as_local_mut().unwrap();
worktree.share(project_id, cx).detach_and_log_err(cx) worktree.share(project_id, cx).detach_and_log_err(cx)
}); });
} }
}
for tx in txs.drain(..) { for tx in txs.drain(..) {
let _ = tx.send(()); let _ = tx.send(());