Make sure not to signal the main thread on fs events in ignored directories (#12436)

Release Notes:

- N/A
This commit is contained in:
Max Brunsfeld 2024-05-29 09:11:28 -07:00 committed by GitHub
parent 66affa969a
commit 2772f87198
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3524,6 +3524,15 @@ impl BackgroundScanner {
})
.collect::<Vec<_>>();
{
let mut state = self.state.lock();
let is_idle = state.snapshot.completed_scan_id == state.snapshot.scan_id;
state.snapshot.scan_id += 1;
if is_idle {
state.snapshot.completed_scan_id = state.snapshot.scan_id;
}
}
self.reload_entries_for_paths(
root_path,
root_canonical_path,
@ -3532,6 +3541,7 @@ impl BackgroundScanner {
None,
)
.await;
self.send_status_update(scanning, Some(request.done))
}
@ -3605,19 +3615,23 @@ impl BackgroundScanner {
}
});
let (scan_job_tx, scan_job_rx) = channel::unbounded();
if !relative_paths.is_empty() || !dot_git_paths.is_empty() {
log::debug!("received fs events {:?}", relative_paths);
self.reload_entries_for_paths(
root_path,
root_canonical_path,
&relative_paths,
abs_paths,
Some(scan_job_tx.clone()),
)
.await;
if relative_paths.is_empty() && dot_git_paths.is_empty() {
return;
}
self.state.lock().snapshot.scan_id += 1;
let (scan_job_tx, scan_job_rx) = channel::unbounded();
log::debug!("received fs events {:?}", relative_paths);
self.reload_entries_for_paths(
root_path,
root_canonical_path,
&relative_paths,
abs_paths,
Some(scan_job_tx.clone()),
)
.await;
self.update_ignore_statuses(scan_job_tx).await;
self.scan_dirs(false, scan_job_rx).await;
@ -4025,13 +4039,7 @@ impl BackgroundScanner {
.await;
let mut state = self.state.lock();
let snapshot = &mut state.snapshot;
let is_idle = snapshot.completed_scan_id == snapshot.scan_id;
let doing_recursive_update = scan_queue_tx.is_some();
snapshot.scan_id += 1;
if is_idle && !doing_recursive_update {
snapshot.completed_scan_id = snapshot.scan_id;
}
// Remove any entries for paths that no longer exist or are being recursively
// refreshed. Do this before adding any new entries, so that renames can be