mirror of https://github.com/telemt/telemt.git
Add config path canonicalization
Canonicalize the config path to match notify events.
This commit is contained in:
parent
953fab68c4
commit
ea88a40c8f
|
|
@ -319,6 +319,13 @@ pub fn spawn_config_watcher(
|
||||||
// Bridge: sync notify callback → async task via mpsc.
|
// Bridge: sync notify callback → async task via mpsc.
|
||||||
let (notify_tx, mut notify_rx) = mpsc::channel::<()>(4);
|
let (notify_tx, mut notify_rx) = mpsc::channel::<()>(4);
|
||||||
|
|
||||||
|
// Canonicalize the config path so it matches what notify returns in events
|
||||||
|
// (notify always gives absolute paths, but config_path may be relative).
|
||||||
|
let config_path = match config_path.canonicalize() {
|
||||||
|
Ok(p) => p,
|
||||||
|
Err(_) => config_path.to_path_buf(), // file doesn't exist yet, use as-is
|
||||||
|
};
|
||||||
|
|
||||||
// Watch the parent directory rather than the file itself, because many
|
// Watch the parent directory rather than the file itself, because many
|
||||||
// editors (vim, nano, systemd-sysusers) write via rename, which would
|
// editors (vim, nano, systemd-sysusers) write via rename, which would
|
||||||
// cause inotify to lose track of the original inode.
|
// cause inotify to lose track of the original inode.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue