From f427f24586deae4a7340f7f2ae08aaeb9ceab869 Mon Sep 17 00:00:00 2001 From: KFears Date: Sat, 18 Nov 2023 14:14:45 +0400 Subject: [PATCH] Use PollWatcher to always get filesystem updates See https://github.com/rust-lang/mdBook/issues/2102#issuecomment-1810982299 for explanation on this Closes #2102, #2035, #383 and #1441 --- src/cmd/watch.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 80b9ff1b..53d54ae6 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -4,6 +4,7 @@ use ignore::gitignore::Gitignore; use mdbook::errors::Result; use mdbook::utils; use mdbook::MDBook; +use notify_debouncer_mini::Config; use pathdiff::diff_paths; use std::path::{Path, PathBuf}; use std::sync::mpsc::channel; @@ -117,8 +118,17 @@ where // Create a channel to receive the events. let (tx, rx) = channel(); + // Notify backend configuration + let backend_config = notify::Config::default().with_poll_interval(Duration::from_secs(1)); + // Debouncer configuration + let debouncer_config = Config::default() + .with_timeout(Duration::from_secs(1)) + .with_notify_config(backend_config); - let mut debouncer = match notify_debouncer_mini::new_debouncer(Duration::from_secs(1), tx) { + let mut debouncer = match notify_debouncer_mini::new_debouncer_opt::<_, notify::PollWatcher>( + debouncer_config, + tx, + ) { Ok(d) => d, Err(e) => { error!("Error while trying to watch the files:\n\n\t{:?}", e);