summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2022-11-15 09:10:08 -0500
committerGitHub <noreply@github.com>2022-11-15 14:10:08 +0000
commitd92a8a0e16eda3df7566e5c995aa0d258b6b76f7 (patch)
tree6adf44d797b8bb1e0842b59fd75473cacb7e08cd
parent778558060243505d07b0850a115e3944862db5cd (diff)
downloadalacritty-d92a8a0e16eda3df7566e5c995aa0d258b6b76f7.tar.gz
alacritty-d92a8a0e16eda3df7566e5c995aa0d258b6b76f7.zip
Update to notify v5 via notify_debouncer_mini
Notify v5 moved the debounced API into the notify_debouncer_mini crate. The debounced API doesn't provide details on the type of event that happened, just that a list of events or errors happened. Therefore, reload is triggered on any event for a matching path. Co-authored-by: Christian Duerr <contact@christianduerr.com>
-rw-r--r--Cargo.lock78
-rw-r--r--alacritty/Cargo.toml2
-rw-r--r--alacritty/src/config/monitor.rs32
3 files changed, 74 insertions, 38 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fa2eac1d..25471d1a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -28,7 +28,7 @@ dependencies = [
"glutin",
"libc",
"log",
- "notify",
+ "notify-debouncer-mini",
"objc",
"once_cell",
"parking_lot 0.12.1",
@@ -375,6 +375,25 @@ dependencies = [
]
[[package]]
+name = "crossbeam-channel"
+version = "0.5.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
+dependencies = [
+ "cfg-if 1.0.0",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
+[[package]]
name = "crossfont"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -609,20 +628,10 @@ dependencies = [
]
[[package]]
-name = "fsevent"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
-dependencies = [
- "bitflags",
- "fsevent-sys",
-]
-
-[[package]]
name = "fsevent-sys"
-version = "2.0.1"
+version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
+checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
dependencies = [
"libc",
]
@@ -756,9 +765,9 @@ dependencies = [
[[package]]
name = "inotify"
-version = "0.7.1"
+version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f"
+checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
dependencies = [
"bitflags",
"inotify-sys",
@@ -833,6 +842,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]]
+name = "kqueue"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c8fc60ba15bf51257aa9807a48a61013db043fcf3a78cb0d916e8e396dcad98"
+dependencies = [
+ "kqueue-sys",
+ "libc",
+]
+
+[[package]]
+name = "kqueue-sys"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587"
+dependencies = [
+ "bitflags",
+ "libc",
+]
+
+[[package]]
name = "lazy-bytes-cast"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1121,23 +1150,32 @@ dependencies = [
[[package]]
name = "notify"
-version = "4.0.17"
+version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257"
+checksum = "ed2c66da08abae1c024c01d635253e402341b4060a12e99b31c7594063bf490a"
dependencies = [
"bitflags",
+ "crossbeam-channel",
"filetime",
- "fsevent",
"fsevent-sys",
"inotify",
+ "kqueue",
"libc",
- "mio 0.6.23",
- "mio-extras",
+ "mio 0.8.4",
"walkdir",
"winapi 0.3.9",
]
[[package]]
+name = "notify-debouncer-mini"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e23e9fa24f094b143c1eb61f90ac6457de87be6987bc70746e0179f7dbc9007b"
+dependencies = [
+ "notify",
+]
+
+[[package]]
name = "num_enum"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index c414e766..307b8c8c 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -31,7 +31,7 @@ serde_yaml = "0.8"
serde_json = "1"
glutin = { version = "0.30.0", default-features = false, features = ["egl", "wgl"] }
winit = { version = "0.27.4", default-features = false, features = ["serde"] }
-notify = "4"
+notify-debouncer-mini = { version = "0.2.1", default-features = false }
parking_lot = "0.12.0"
crossfont = { version = "0.5.0", features = ["force_system_fontconfig"] }
copypasta = { version = "0.8.1", default-features = false }
diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs
index f6d52e2f..622a993b 100644
--- a/alacritty/src/config/monitor.rs
+++ b/alacritty/src/config/monitor.rs
@@ -3,7 +3,8 @@ use std::sync::mpsc;
use std::time::Duration;
use log::{debug, error};
-use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
+use notify_debouncer_mini::new_debouncer;
+use notify_debouncer_mini::notify::RecursiveMode;
use winit::event_loop::EventLoopProxy;
use alacritty_terminal::thread;
@@ -40,8 +41,8 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
// The Duration argument is a debouncing period.
let (tx, rx) = mpsc::channel();
- let mut watcher = match watcher(tx, DEBOUNCE_DELAY) {
- Ok(watcher) => watcher,
+ let mut debouncer = match new_debouncer(DEBOUNCE_DELAY, None, tx) {
+ Ok(debouncer) => debouncer,
Err(err) => {
error!("Unable to watch config file: {}", err);
return;
@@ -61,6 +62,7 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
parents.sort_unstable();
parents.dedup();
+ let watcher = debouncer.watcher();
// Watch all configuration file directories.
for parent in &parents {
if let Err(err) = watcher.watch(parent, RecursiveMode::NonRecursive) {
@@ -69,26 +71,22 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
}
loop {
- let event = match rx.recv() {
- Ok(event) => event,
+ let events = match rx.recv() {
+ Ok(Ok(events)) => events,
+ Ok(Err(err)) => {
+ debug!("Config watcher errors: {:?}", err);
+ continue;
+ },
Err(err) => {
debug!("Config watcher channel dropped unexpectedly: {}", err);
break;
},
};
- match event {
- DebouncedEvent::Rename(_, path)
- | DebouncedEvent::Write(path)
- | DebouncedEvent::Create(path)
- | DebouncedEvent::Chmod(path)
- if paths.contains(&path) =>
- {
- // Always reload the primary configuration file.
- let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
- let _ = event_proxy.send_event(event);
- },
- _ => (),
+ if events.iter().any(|e| paths.contains(&e.path)) {
+ // Always reload the primary configuration file.
+ let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
+ let _ = event_proxy.send_event(event);
}
}
});