notify
notify copied to clipboard
Wrong / duplicate events on macOS ?
System details
- MacOS Mojave
- rust 1.47.0
- notify = "5.0.0-pre.4"
What you did (as detailed as you can)
let mut watcher: RecommendedWatcher =
Watcher::new_immediate(|res|
match res {
Ok(event) => println!("event: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
).unwrap();
watcher.watch(".", RecursiveMode::Recursive).unwrap();
touch somefile
rm somefile
What you expected
event: Event { kind: Create(File), paths: ["/Users/hbollamreddi/git/rums/somefile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
event: Event { kind: Remove(File), paths: ["/Users/hbollamreddi/git/rums/somefile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
What happened
event: Event { kind: Create(File), paths: ["/Users/hbollamreddi/git/rums/somefile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
event: Event { kind: Create(File), paths: ["/Users/hbollamreddi/git/rums/somefile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
event: Event { kind: Remove(File), paths: ["/Users/hbollamreddi/git/rums/somefile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
It looks like a bug of FSEvent API. Many people reported this weird behavior. Sometimes multiple recent events on the same file may get merged into a single event.
ref: https://github.com/haskell-fswatch/hfsnotify/issues/36