Grab latest snapshot when invoking LocalWorktree::poll_snapshot

This commit is contained in:
Antonio Scandurra 2022-07-01 14:36:51 +02:00
parent 833aa726d5
commit a42399bcf3

View file

@ -495,10 +495,10 @@ impl LocalWorktree {
} }
fn poll_snapshot(&mut self, cx: &mut ModelContext<Worktree>) { fn poll_snapshot(&mut self, cx: &mut ModelContext<Worktree>) {
self.poll_task.take();
self.snapshot = self.background_snapshot.lock().clone();
match self.scan_state() { match self.scan_state() {
ScanState::Idle => { ScanState::Idle => {
self.poll_task.take();
self.snapshot = self.background_snapshot.lock().clone();
if let Some(share) = self.share.as_mut() { if let Some(share) = self.share.as_mut() {
*share.snapshots_tx.borrow_mut() = self.snapshot.clone(); *share.snapshots_tx.borrow_mut() = self.snapshot.clone();
} }
@ -516,10 +516,7 @@ impl LocalWorktree {
smol::Timer::after(Duration::from_millis(100)).await; smol::Timer::after(Duration::from_millis(100)).await;
} }
if let Some(this) = this.upgrade(&cx) { if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| this.poll_snapshot(cx));
this.as_local_mut().unwrap().poll_task = None;
this.poll_snapshot(cx);
});
} }
})); }));
} }