From 6767948daaa49c77c9772a9bdba80029333cf98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Tue, 24 Aug 2021 22:28:29 +1200 Subject: [PATCH] Specify delay for fs Poll mode --- lib/src/fs.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/fs.rs b/lib/src/fs.rs index ad69e16..99a6dbc 100644 --- a/lib/src/fs.rs +++ b/lib/src/fs.rs @@ -4,6 +4,8 @@ use std::{ collections::{HashMap, HashSet}, mem::take, path::PathBuf, + sync::{Arc, Mutex}, + time::Duration, }; use notify::Watcher as _; @@ -23,7 +25,7 @@ use crate::{ #[non_exhaustive] pub enum Watcher { Native, - Poll, + Poll(Duration), } impl Default for Watcher { @@ -39,7 +41,8 @@ impl Watcher { ) -> Result, RuntimeError> { match self { Self::Native => notify::RecommendedWatcher::new(f).map(|w| Box::new(w) as _), - Self::Poll => notify::PollWatcher::new(f).map(|w| Box::new(w) as _), + Self::Poll(delay) => notify::PollWatcher::with_delay(Arc::new(Mutex::new(f)), delay) + .map(|w| Box::new(w) as _), } .map_err(|err| RuntimeError::FsWatcherCreate { kind: self, err }) }