Flush the fs event stream on construction

This commit is contained in:
Max Brunsfeld 2021-04-27 21:43:41 -07:00
parent c1d35b099b
commit 1eba61c08d

View File

@ -82,6 +82,15 @@ impl EventStream {
);
cf::CFRelease(cf_paths);
fs::FSEventStreamScheduleWithRunLoop(
stream,
cf::CFRunLoopGetCurrent(),
cf::kCFRunLoopDefaultMode,
);
fs::FSEventStreamStart(stream);
fs::FSEventStreamFlushSync(stream);
fs::FSEventStreamStop(stream);
let state = Arc::new(Mutex::new(Lifecycle::New));
(
@ -111,12 +120,8 @@ impl EventStream {
}
}
fs::FSEventStreamScheduleWithRunLoop(self.stream, run_loop, cf::kCFRunLoopDefaultMode);
fs::FSEventStreamStart(self.stream);
cf::CFRunLoopRun();
fs::FSEventStreamFlushSync(self.stream);
fs::FSEventStreamStop(self.stream);
fs::FSEventStreamRelease(self.stream);
}
}
@ -133,11 +138,12 @@ impl EventStream {
let event_paths = event_paths as *const *const ::std::os::raw::c_char;
let e_ptr = event_flags as *mut u32;
let i_ptr = event_ids as *mut u64;
let callback = (info as *mut Option<RunCallback>)
.as_mut()
.unwrap()
.as_mut()
.unwrap();
let callback_ptr = (info as *mut Option<RunCallback>).as_mut().unwrap();
let callback = if let Some(callback) = callback_ptr.as_mut() {
callback
} else {
return;
};
let paths = slice::from_raw_parts(event_paths, num);
let flags = slice::from_raw_parts_mut(e_ptr, num);