Skip to content

macOS watcher event-mapping: delete coalesced to Modify, rename split into Creates #5

Open

Description

@utof

Context

On macOS, notify's FSEvents backend coalesces filesystem events differently than Linux's inotify:

  • File deletion is reported as EventKind::Modify(Any) (not Remove), so the watcher maps it to FileEvent::Modified → status Stale instead of Missing.
  • File rename is split into two Create events (old path empty, new path present) instead of a single Modify(Name(Both)), so the watcher fires FileEvent::Created twice instead of Renamed.

This was discovered during phase 3a CI — Linux watcher tests pass, macOS tests failed. Tests are currently gated behind #[cfg(target_os = "linux")] with a WHY comment.

Impact

On macOS, a user who deletes a file in a watched dir will see it remain Active (never flipped to Missing) until the next perima scan. Same for renames — the old path will be orphaned.

Action

Extend map_event in crates/fs/src/watcher.rs to recognize macOS-specific event patterns:

  1. Modify(Any) on a path that no longer exists → treat as Deleted.
  2. Two consecutive Create events where the first path is the watcher root itself → buffer and emit as Renamed if a matching Remove follows within the debounce window.

Alternative: switch to notify::PollWatcher on macOS (simpler semantics but higher CPU).

Priority

Medium — affects macOS users specifically. Worth a proper fix before the v1 release. Linux behavior is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions