You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once a file (only a single file is being watched) gets modified, the Modify event gets triggered. Any consecutive modifications of the watched file do not result in the Modify event getting triggered. Not sure whether this is an issue with my code or not – help will be appreciated. Here is the code:
let(tx, rx) = mpsc::channel::<notify::Result<notify::Event>>();letmut watcher =
match notify::RecommendedWatcher::new(tx.clone(), notify::Config::default()){Ok(w) => w,Err(e) => {eprintln!("Failed to create watcher: {:?}", e);return;}};ifletErr(e) = watcher.watch(Path::new(&config_path.clone()),
notify::RecursiveMode::Recursive,){eprintln!("Failed to watch config file: {:?}", e);return;}// Block forever, printing out events as they come infor res in rx {ifletErr(e) = res {println!("watch error: {:?}", e);continue;}let event = res.unwrap();println!("event: {:?}", event);match event.kind{
notify::EventKind::Modify(_) => {// Refresh configlet config_file = get_file(&config_path);letmut p = Parser::new(config_file);let cfg = p.parse();ifletOk(cfg) = cfg {letmut config_guard = config.lock().unwrap();*config_guard = cfg;println!("Config updated: {:#?}", config_guard);}}
_ => {}}}
The text was updated successfully, but these errors were encountered:
Once a file (only a single file is being watched) gets modified, the
Modify
event gets triggered. Any consecutive modifications of the watched file do not result in theModify
event getting triggered. Not sure whether this is an issue with my code or not – help will be appreciated. Here is the code:The text was updated successfully, but these errors were encountered: