Skip to content

Commit

Permalink
purge events on stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Will authored and 0xpr03 committed Jan 4, 2024
1 parent 6c1798d commit c3929ed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions notify/src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ impl FsEventWatcher {

cf::CFRunLoopRun();
fs::FSEventStreamStop(stream);
// There are edge-cases, when many events are pending,
// despite the stream being stopped, that the stream's
// associated callback will be invoked. Purging events
// is intended to prevent this.
let event_id = fs::FSEventsGetCurrentEventId();
let device = fs::FSEventStreamGetDeviceBeingWatched(stream);
fs::FSEventsPurgeEventsForDeviceUpToEventId(device, event_id);
fs::FSEventStreamInvalidate(stream);
fs::FSEventStreamRelease(stream);
}
Expand Down

0 comments on commit c3929ed

Please sign in to comment.