diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-10 21:02:31 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-10 21:02:31 +0200 |
commit | b07cd5d816a5c824d923053a7d24904ef9b23a35 (patch) | |
tree | d918ca4ea5782e08c10865b999a09838575dd265 | |
parent | 518cbf0c2658bb43ba2297df973a3c2b1b3dca61 (diff) | |
download | gnix-b07cd5d816a5c824d923053a7d24904ef9b23a35.tar gnix-b07cd5d816a5c824d923053a7d24904ef9b23a35.tar.bz2 gnix-b07cd5d816a5c824d923053a7d24904ef9b23a35.tar.zst |
config watch only reacts to config file not other files in dir
-rw-r--r-- | src/config.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/config.rs b/src/config.rs index 9473784..020e1e2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -229,15 +229,17 @@ pub fn setup_file_watch(config_path: PathBuf, state: Arc<State>) { for event in events { if event.mask.contains(EventMask::MODIFY) { - 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) + 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:?}"), } - Err(e) => error!("config has errors: {e:?}"), } } } |