Add config path canonicalization

Canonicalize the config path to match notify events.
This commit is contained in:
artemws 2026-02-20 15:37:44 +02:00 committed by GitHub
parent 953fab68c4
commit ea88a40c8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -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.