summaryrefslogtreecommitdiff
path: root/alacritty/src/config/monitor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/config/monitor.rs')
-rw-r--r--alacritty/src/config/monitor.rs37
1 files changed, 16 insertions, 21 deletions
diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs
index 4a694fac..e3dd0556 100644
--- a/alacritty/src/config/monitor.rs
+++ b/alacritty/src/config/monitor.rs
@@ -1,4 +1,3 @@
-use std::fs;
use std::path::PathBuf;
use std::sync::mpsc;
use std::time::Duration;
@@ -16,23 +15,21 @@ const DEBOUNCE_DELAY: Duration = Duration::from_millis(10);
const DEBOUNCE_DELAY: Duration = Duration::from_millis(1000);
pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventProxy) {
- // Canonicalize all paths, filtering out the ones that do not exist.
- paths = paths
- .drain(..)
- .filter_map(|path| match fs::canonicalize(&path) {
- Ok(path) => Some(path),
- Err(err) => {
- error!("Unable to canonicalize config path {:?}: {}", path, err);
- None
- },
- })
- .collect();
-
// Don't monitor config if there is no path to watch.
if paths.is_empty() {
return;
}
+ // Canonicalize paths, keeping the base paths for symlinks.
+ for i in 0..paths.len() {
+ if let Ok(canonical_path) = paths[i].canonicalize() {
+ match paths[i].symlink_metadata() {
+ Ok(metadata) if metadata.file_type().is_symlink() => paths.push(canonical_path),
+ _ => paths[i] = canonical_path,
+ }
+ }
+ }
+
// The Duration argument is a debouncing period.
let (tx, rx) = mpsc::channel();
let mut watcher = match watcher(tx, DEBOUNCE_DELAY) {
@@ -73,17 +70,15 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventProxy) {
};
match event {
- DebouncedEvent::Rename(..) => continue,
- DebouncedEvent::Write(path)
+ DebouncedEvent::Rename(_, path)
+ | DebouncedEvent::Write(path)
| DebouncedEvent::Create(path)
- | DebouncedEvent::Chmod(path) => {
- if !paths.contains(&path) {
- continue;
- }
-
+ | DebouncedEvent::Chmod(path)
+ if paths.contains(&path) =>
+ {
// Always reload the primary configuration file.
event_proxy.send_event(Event::ConfigReload(paths[0].clone()));
- },
+ }
_ => {},
}
}