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
This commit is contained in:
KFears 2023-11-18 14:14:45 +04:00
parent b7f46213c7
commit f427f24586
No known key found for this signature in database
1 changed files with 11 additions and 1 deletions

View File

@ -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);