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

张小白 created

Follow up #27498

Release Notes:

- N/A

Change summary

crates/fs/src/fs_watcher.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Detailed changes

crates/fs/src/fs_watcher.rs 🔗

@@ -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)