Skip to content

Built-in event filtering of Ops #7

@nathany

Description

@nathany

The current mechanism for filtering events is to inspect the Op bitmask:

if event.Op&fsnotify.Create == fsnotify.Create {

In howeyc/fsnotify there is a WatchFlags method to filter operations. WatchFlags was removed in 10e1440 (v0.10.0) because:

  • The implementation required a lot of extra bookkeeping while providing little benefit over filtering events as they were received.
  • As @mstum reported, it wasn't working on Windows, which was due to the bookkeeping not being implemented for files within a directory watch: WatchFlags not supported on Windows? howeyc/fsnotify#93 (comment).
  • There were no tests for WatchFlags.

@nightlyone pointed out that it still is desirable to specify filters so the kernel doesn't need to wakeup our thread/process for an event we'll just ignore.

Some research (API doc) reveal differences from one OS to the next:

  • kqueue doesn't have a Create Op at all (NOTE_CREATE), much less a filter for it.
  • Windows has a filter for FILE_NOTIFY_CHANGE_FILE_NAME that covers Create, Remove and Rename. An event does indicate which one of these it is, but some user-space filtering is still necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions