aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-10 21:07:13 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-10 21:07:13 +0200
commit5a2251390b0dc89f6383a054f6f596a416c91e3e (patch)
treeefb94a0ac4ecdb069164eb7281c338b65dc6312c /src
parentb07cd5d816a5c824d923053a7d24904ef9b23a35 (diff)
downloadgnix-5a2251390b0dc89f6383a054f6f596a416c91e3e.tar
gnix-5a2251390b0dc89f6383a054f6f596a416c91e3e.tar.bz2
gnix-5a2251390b0dc89f6383a054f6f596a416c91e3e.tar.zst
fixup: config watches
Diffstat (limited to 'src')
-rw-r--r--src/config.rs24
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:?}"),
}
}
}