Move the EventKind::Access filtering before the loop starts (#27569)

Follow up #27498

Release Notes:

- N/A
This commit is contained in:
张小白 2025-03-27 15:15:24 +08:00 committed by GitHub
parent a7697be857
commit 926d10cc45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,9 +38,6 @@ impl Watcher for FsWatcher {
EventKind::Create(_) => Some(PathEventKind::Created),
EventKind::Modify(_) => Some(PathEventKind::Changed),
EventKind::Remove(_) => Some(PathEventKind::Removed),
// Adding this fix a weird bug on Linux after upgrading notify
// https://github.com/zed-industries/zed/actions/runs/14085230504/job/39449448832
EventKind::Access(_) => return,
_ => None,
};
let mut path_events = event
@ -108,7 +105,14 @@ static FS_WATCHER_INSTANCE: OnceLock<anyhow::Result<GlobalWatcher, notify::Error
OnceLock::new();
fn handle_event(event: Result<notify::Event, notify::Error>) {
let Some(event) = event.log_err() else { return };
// Filter out access events, which could lead to a weird bug on Linux after upgrading notify
// https://github.com/zed-industries/zed/actions/runs/14085230504/job/39449448832
let Some(event) = event
.log_err()
.filter(|event| !matches!(event.kind, EventKind::Access(_)))
else {
return;
};
global::<()>(move |watcher| {
for f in watcher.watchers.lock().iter() {
f(&event)