From 48ff443d106377a79e94ae5e8ddf5c5431790ba4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 22 Jun 2022 19:40:52 +0200 Subject: [PATCH 1/2] Remove stray log statement when contacts are updated Co-Authored-By: Max Brunsfeld --- crates/client/src/user.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index 3dc573a8a3..5e56b53b87 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -230,11 +230,6 @@ impl UserStore { Task::ready(Ok(())) } UpdateContacts::Update(message) => { - log::info!( - "update contacts on client {}: {:?}", - self.client.upgrade().unwrap().id, - message - ); let mut user_ids = HashSet::default(); for contact in &message.contacts { user_ids.insert(contact.user_id); From 2d8ffbdfa24c460f0a9f860071dac8d40839bb76 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 22 Jun 2022 19:45:55 +0200 Subject: [PATCH 2/2] Don't wait for host's worktree updates if they disconnected Co-Authored-By: Max Brunsfeld --- crates/project/src/project.rs | 9 +++++++++ crates/project/src/worktree.rs | 16 +++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 1eb7616d92..612dcbdbcf 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1343,6 +1343,15 @@ impl Project { { *sharing_has_stopped = true; self.collaborators.clear(); + for worktree in &self.worktrees { + if let Some(worktree) = worktree.upgrade(cx) { + worktree.update(cx, |worktree, _| { + if let Some(worktree) = worktree.as_remote_mut() { + worktree.disconnected_from_host(); + } + }); + } + } cx.notify(); } } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index d5e9b392e7..befcfe9fd1 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -81,7 +81,7 @@ pub struct RemoteWorktree { pub(crate) background_snapshot: Arc>, project_id: u64, client: Arc, - updates_tx: UnboundedSender, + updates_tx: Option>, last_scan_id_rx: watch::Receiver, replica_id: ReplicaId, diagnostic_summaries: TreeMap, @@ -202,7 +202,7 @@ impl Worktree { replica_id, snapshot: snapshot.clone(), background_snapshot: background_snapshot.clone(), - updates_tx, + updates_tx: Some(updates_tx), last_scan_id_rx, client: client.clone(), diagnostic_summaries: TreeMap::from_ordered_entries( @@ -1042,13 +1042,19 @@ impl RemoteWorktree { self.snapshot.clone() } + pub fn disconnected_from_host(&mut self) { + self.updates_tx.take(); + } + pub fn update_from_remote( &mut self, envelope: TypedEnvelope, ) -> Result<()> { - self.updates_tx - .unbounded_send(envelope.payload) - .expect("consumer runs to completion"); + if let Some(updates_tx) = &self.updates_tx { + updates_tx + .unbounded_send(envelope.payload) + .expect("consumer runs to completion"); + } Ok(()) }