diff options
-rw-r--r-- | src/config.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/config.rs b/src/config.rs index 020e1e2..7b46944 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use crate::{ State, }; use anyhow::Context; -use inotify::{EventMask, Inotify, WatchMask}; +use inotify::{Inotify, WatchMask}; use log::{error, info}; use rand::random; use serde::{ @@ -218,7 +218,7 @@ pub fn setup_file_watch(config_path: PathBuf, state: Arc<State>) { .watches() .add( config_path.parent().unwrap(), - WatchMask::MODIFY | WatchMask::CREATE | WatchMask::DELETE, + WatchMask::MODIFY | WatchMask::CREATE | WatchMask::DELETE | WatchMask::MOVED_TO, ) .unwrap(); let mut buffer = [0u8; 4096]; @@ -228,18 +228,16 @@ pub fn setup_file_watch(config_path: PathBuf, state: Arc<State>) { .expect("Failed to read inotify events"); for event in events { - if event.mask.contains(EventMask::MODIFY) { - if event.name == config_path.file_name() { - if config_path.metadata().map(|m| m.len()).unwrap_or_default() == 0 { - continue; - } - match Config::load(&config_path) { - Ok(conf) => { - let mut r = state.config.blocking_write(); - *r = Arc::new(conf) - } - Err(e) => error!("config has errors: {e:?}"), + if event.name == config_path.file_name() { + if config_path.metadata().map(|m| m.len()).unwrap_or_default() == 0 { + continue; + } + match Config::load(&config_path) { + Ok(conf) => { + let mut r = state.config.blocking_write(); + *r = Arc::new(conf) } + Err(e) => error!("config has errors: {e:?}"), } } } |