Don't spawn notify unnecessary

This commit is contained in:
Aleksey Kladov 2020-07-10 23:39:25 +02:00
parent 65984773d3
commit dac9a4cebd
3 changed files with 8 additions and 6 deletions

View file

@ -182,6 +182,7 @@ impl GlobalState {
} }
}, },
}; };
let watch = match self.config.files.watcher { let watch = match self.config.files.watcher {
FilesWatcher::Client => vec![], FilesWatcher::Client => vec![],
FilesWatcher::Notify => project_folders.watch, FilesWatcher::Notify => project_folders.watch,

View file

@ -1,5 +1,4 @@
//! See `Include`. //! See `Include`.
use std::convert::TryFrom; use std::convert::TryFrom;
use globset::{Glob, GlobSet, GlobSetBuilder}; use globset::{Glob, GlobSet, GlobSetBuilder};

View file

@ -82,11 +82,13 @@ impl NotifyActor {
Event::Message(msg) => match msg { Event::Message(msg) => match msg {
Message::Config(config) => { Message::Config(config) => {
self.watcher = None; self.watcher = None;
if !config.watch.is_empty() {
let (watcher_sender, watcher_receiver) = unbounded(); let (watcher_sender, watcher_receiver) = unbounded();
let watcher = log_notify_error(Watcher::new_immediate(move |event| { let watcher = log_notify_error(Watcher::new_immediate(move |event| {
watcher_sender.send(event).unwrap() watcher_sender.send(event).unwrap()
})); }));
self.watcher = watcher.map(|it| (it, watcher_receiver)); self.watcher = watcher.map(|it| (it, watcher_receiver));
}
let n_total = config.load.len(); let n_total = config.load.len();
self.send(loader::Message::Progress { n_total, n_done: 0 }); self.send(loader::Message::Progress { n_total, n_done: 0 });