Move swaplock to the root

This commit is contained in:
Félix Saparelli 2022-01-28 23:32:54 +13:00
parent 18a2b204e2
commit c444895593
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
4 changed files with 11 additions and 9 deletions

View File

@ -18,13 +18,13 @@ use crate::filter::Filterer;
use crate::ignore::{IgnoreFile, IgnoreFilterer};
use crate::signal::process::SubSignal;
use crate::signal::source::MainSignal;
use crate::swaplock::SwapLock;
// to make filters
pub use regex::Regex;
pub mod files;
mod parse;
pub mod swaplock;
/// A filterer implementation that exposes the full capabilities of Watchexec.
///
@ -112,16 +112,16 @@ pub struct TaggedFilterer {
workdir: PathBuf,
/// All filters that are applied, in order, by matcher.
filters: swaplock::SwapLock<HashMap<Matcher, Vec<Filter>>>,
filters: SwapLock<HashMap<Matcher, Vec<Filter>>>,
/// Sub-filterer for ignore files.
ignore_filterer: swaplock::SwapLock<IgnoreFilterer>,
ignore_filterer: SwapLock<IgnoreFilterer>,
/// Compiled matcher for Glob filters.
glob_compiled: swaplock::SwapLock<Option<Gitignore>>,
glob_compiled: SwapLock<Option<Gitignore>>,
/// Compiled matcher for NotGlob filters.
not_glob_compiled: swaplock::SwapLock<Option<Gitignore>>,
not_glob_compiled: SwapLock<Option<Gitignore>>,
}
impl Filterer for TaggedFilterer {
@ -333,10 +333,10 @@ impl TaggedFilterer {
err,
})?;
Ok(Arc::new(Self {
filters: swaplock::SwapLock::new(HashMap::new()),
ignore_filterer: swaplock::SwapLock::new(IgnoreFilterer::empty(&origin)),
glob_compiled: swaplock::SwapLock::new(None),
not_glob_compiled: swaplock::SwapLock::new(None),
filters: SwapLock::new(HashMap::new()),
ignore_filterer: SwapLock::new(IgnoreFilterer::empty(&origin)),
glob_compiled: SwapLock::new(None),
not_glob_compiled: SwapLock::new(None),
workdir: canonicalize(workdir.into()).map_err(|err| TaggedFiltererError::IoError {
about: "canonicalise workdir on new tagged filterer",
err,

View File

@ -108,6 +108,7 @@ pub mod ignore;
pub mod paths;
pub mod project;
pub mod signal;
pub mod swaplock;
// the core experience
pub mod config;

View File

@ -97,6 +97,7 @@ impl Watchexec {
let error_hook = subtask!(error_hook, error_hook(er_r, eh));
// Use Tokio TaskSet when that lands
try_join!(action, error_hook, fs, signal)
.map(drop)
.or_else(|e| {