Skip to content

Commit

Permalink
Use PollWatcher to always get filesystem updates
Browse files Browse the repository at this point in the history
See #2102 (comment)
for explanation on this

Closes #2102, #2035, #383 and #1441
  • Loading branch information
KFearsoff committed Dec 3, 2023
1 parent b7f4621 commit f427f24
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cmd/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,8 +118,17 @@ where

// Create a channel to receive the events.
let (tx, rx) = channel();

let mut debouncer = match notify_debouncer_mini::new_debouncer(Duration::from_secs(1), tx) {
// 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_opt::<_, notify::PollWatcher>(
debouncer_config,
tx,
) {
Ok(d) => d,
Err(e) => {
error!("Error while trying to watch the files:\n\n\t{:?}", e);
Expand Down

0 comments on commit f427f24

Please sign in to comment.