Ignore 'historical' events from fs event stream

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2021-04-27 16:49:56 -07:00
parent 907b537a0b
commit c1d35b099b

View file

@ -148,19 +148,25 @@ impl EventStream {
let path_c_str = CStr::from_ptr(paths[p]); let path_c_str = CStr::from_ptr(paths[p]);
let path = PathBuf::from(OsStr::from_bytes(path_c_str.to_bytes())); let path = PathBuf::from(OsStr::from_bytes(path_c_str.to_bytes()));
if let Some(flag) = StreamFlags::from_bits(flags[p]) { if let Some(flag) = StreamFlags::from_bits(flags[p]) {
events.push(Event { if flag.contains(StreamFlags::HISTORY_DONE) {
event_id: ids[p], events.clear();
flags: flag, } else {
path, events.push(Event {
}); event_id: ids[p],
flags: flag,
path,
});
}
} else { } else {
debug_assert!(false, "unknown flag set for fs event: {}", flags[p]); debug_assert!(false, "unknown flag set for fs event: {}", flags[p]);
} }
} }
if !callback(events) { if !events.is_empty() {
fs::FSEventStreamStop(stream_ref); if !callback(events) {
cf::CFRunLoopStop(cf::CFRunLoopGetCurrent()); fs::FSEventStreamStop(stream_ref);
cf::CFRunLoopStop(cf::CFRunLoopGetCurrent());
}
} }
} }
} }