From 833aa726d54a67f1b38117e4e92f4ef11dd43c49 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 1 Jul 2022 14:11:21 +0200 Subject: [PATCH] :art: --- crates/project/src/worktree.rs | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index af7cf02cb89c9cd7cb21633f9c07ec2c709ef46c..97ba52a763e7c1f133255c57f4726adceef0b244 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -410,10 +410,7 @@ impl LocalWorktree { while let Some(scan_state) = scan_states_rx.next().await { if let Some(this) = this.upgrade(&cx) { last_scan_state_tx.blocking_send(scan_state).ok(); - this.update(&mut cx, |this, cx| { - this.poll_snapshot(cx); - this.as_local_mut().unwrap().broadcast_snapshot() - }); + this.update(&mut cx, |this, cx| this.poll_snapshot(cx)); } else { break; } @@ -500,8 +497,11 @@ impl LocalWorktree { fn poll_snapshot(&mut self, cx: &mut ModelContext) { match self.scan_state() { ScanState::Idle => { - self.snapshot = self.background_snapshot.lock().clone(); self.poll_task.take(); + self.snapshot = self.background_snapshot.lock().clone(); + if let Some(share) = self.share.as_mut() { + *share.snapshots_tx.borrow_mut() = self.snapshot.clone(); + } cx.emit(Event::UpdatedEntries); } ScanState::Initializing => { @@ -677,7 +677,6 @@ impl LocalWorktree { snapshot.delete_entry(entry_id); } this.poll_snapshot(cx); - this.broadcast_snapshot(); }); Ok(()) })) @@ -717,7 +716,6 @@ impl LocalWorktree { this.update(&mut cx, |this, cx| { let this = this.as_local_mut().unwrap(); this.poll_snapshot(cx); - this.broadcast_snapshot(); }); Ok(entry) })) @@ -757,7 +755,6 @@ impl LocalWorktree { this.update(&mut cx, |this, cx| { let this = this.as_local_mut().unwrap(); this.poll_snapshot(cx); - this.broadcast_snapshot() }); Ok(entry) })) @@ -795,7 +792,6 @@ impl LocalWorktree { this.update(&mut cx, |this, cx| { let this = this.as_local_mut().unwrap(); this.poll_snapshot(cx); - this.broadcast_snapshot(); }); Ok(entry) }) @@ -844,7 +840,6 @@ impl LocalWorktree { snapshot.scan_id += 1; } this.poll_snapshot(cx); - this.broadcast_snapshot(); Ok(inserted_entry) }) }) @@ -936,15 +931,6 @@ impl LocalWorktree { pub fn is_shared(&self) -> bool { self.share.is_some() } - - fn broadcast_snapshot(&mut self) { - if matches!(self.scan_state(), ScanState::Idle) { - let snapshot = self.snapshot(); - if let Some(share) = self.share.as_mut() { - *share.snapshots_tx.borrow_mut() = snapshot; - } - } - } } impl RemoteWorktree {