diff --git a/config/src/lib.rs b/config/src/lib.rs index 8b633bd94..417aa83fc 100755 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -688,7 +688,7 @@ mod tests { use crate::error::Result; use log::LevelFilter; use toml::Value as TomlValue; - use xvc_logging::{setup_logging, watch}; + use xvc_logging::setup_logging; pub fn test_logging(level: LevelFilter) { setup_logging(Some(level), Some(LevelFilter::Trace)); diff --git a/core/src/util/file.rs b/core/src/util/file.rs index 00817c7f2..8641ddcb5 100644 --- a/core/src/util/file.rs +++ b/core/src/util/file.rs @@ -214,6 +214,7 @@ impl XvcPathMetadataProvider { Ok(()) } + /// Return all paths from the disk specified with glob pub fn glob_paths(&self, glob: &str) -> Result { watch!(glob); self.update_with_glob(glob)?; @@ -301,12 +302,6 @@ pub fn compiled_glob(pipeline_rundir: &Path, glob: &str) -> Result Result { - Regex::new(&pat).map_err(|source| Error::RegexError { source }) -} - /// Returns all _non-ignored_ paths described with `glob` under `root_dir` #[cached( type = "UnboundCache", @@ -315,7 +310,6 @@ pub fn compiled_regex(pat: String) -> Result { result = true )] pub fn glob_paths( - xvc_root: &XvcRoot, pmp: &XvcPathMetadataProvider, root_dir: &XvcPath, glob: &str, diff --git a/ecs/src/ecs/hstore.rs b/ecs/src/ecs/hstore.rs index 481725c2e..e62040563 100644 --- a/ecs/src/ecs/hstore.rs +++ b/ecs/src/ecs/hstore.rs @@ -316,7 +316,7 @@ impl HStore { /// Returns the first entity matched with [Self::entities_for] pub fn entity_by_value(&self, value: &T) -> Option { match self.entities_for(value) { - Some(vec_e) => vec_e.get(0).copied(), + Some(vec_e) => vec_e.first().copied(), None => None, } } diff --git a/ecs/src/ecs/r11store.rs b/ecs/src/ecs/r11store.rs index 5ae535798..a472dcd72 100644 --- a/ecs/src/ecs/r11store.rs +++ b/ecs/src/ecs/r11store.rs @@ -117,7 +117,7 @@ where pub fn entity_by_right(&self, right_element: &U) -> Option { match self.right.entities_for(right_element) { None => None, - Some(vec_e) => vec_e.get(0).copied(), + Some(vec_e) => vec_e.first().copied(), } } diff --git a/ecs/src/ecs/xvcstore.rs b/ecs/src/ecs/xvcstore.rs index 51dac1972..1766e2dc5 100644 --- a/ecs/src/ecs/xvcstore.rs +++ b/ecs/src/ecs/xvcstore.rs @@ -308,7 +308,7 @@ where /// Returns the first entity matched with [Self::entities_for] pub fn entity_by_value(&self, value: &T) -> Option { match self.entities_for(value) { - Some(vec_e) => vec_e.get(0).copied(), + Some(vec_e) => vec_e.first().copied(), None => None, } } diff --git a/file/src/common/mod.rs b/file/src/common/mod.rs index 59c1ceb0a..ac3b25407 100644 --- a/file/src/common/mod.rs +++ b/file/src/common/mod.rs @@ -286,7 +286,7 @@ pub fn recheck_from_cache( recheck_method: RecheckMethod, ignore_writer: &Sender, ) -> Result<()> { - if let Some(parent) = xvc_path.parents().get(0) { + if let Some(parent) = xvc_path.parents().first() { watch!(parent); let parent_dir = parent.to_absolute_path(xvc_root); watch!(parent_dir); diff --git a/pipeline/src/pipeline/deps/glob_items.rs b/pipeline/src/pipeline/deps/glob_items.rs index 0a6940569..dba894215 100644 --- a/pipeline/src/pipeline/deps/glob_items.rs +++ b/pipeline/src/pipeline/deps/glob_items.rs @@ -46,7 +46,7 @@ impl GlobItemsDep { pmp: &XvcPathMetadataProvider, ) -> Result { let xvc_path_metadata_map = - glob_paths(xvc_root, pmp, glob_root, &glob).map(|paths| paths.into_iter().collect())?; + glob_paths(pmp, glob_root, &glob).map(|paths| paths.into_iter().collect())?; // We don't calculate the content digest map immediately, we only do that in through comparison Ok(GlobItemsDep { glob, diff --git a/pipeline/src/pipeline/deps/mod.rs b/pipeline/src/pipeline/deps/mod.rs index d934043cb..bdee34241 100644 --- a/pipeline/src/pipeline/deps/mod.rs +++ b/pipeline/src/pipeline/deps/mod.rs @@ -207,7 +207,7 @@ pub fn dependency_paths( .iter() .map(|(xp, xmd)| (xp.clone(), *xmd)) .collect(), - XvcDependency::Glob(dep) => glob_paths(xvc_root, pmp, pipeline_rundir, &dep.glob).unwrap(), + XvcDependency::Glob(dep) => glob_paths(pmp, pipeline_rundir, &dep.glob).unwrap(), XvcDependency::UrlDigest(_) => empty, XvcDependency::Param(dep) => make_map(&dep.path), XvcDependency::RegexItems(dep) => make_map(&dep.path), diff --git a/pipeline/src/pipeline/mod.rs b/pipeline/src/pipeline/mod.rs index ba477cb48..6ee9c1778 100644 --- a/pipeline/src/pipeline/mod.rs +++ b/pipeline/src/pipeline/mod.rs @@ -781,59 +781,6 @@ fn step_state_handler(step_e: XvcEntity, params: StepThreadParams) -> Result<()> } } -fn update_pmp( - xvc_root: &XvcRoot, - fs_receiver: Receiver>, - pmm: &mut XvcPathMetadataMap, - kill_signal_receiver: Receiver, -) -> Result<()> { - let mut handle_fs_event = |fs_event| match fs_event { - PathEvent::Create { path, metadata } => { - let xvc_path = XvcPath::new(xvc_root, xvc_root, &path).unwrap(); - let xvc_md = XvcMetadata::from(metadata); - pmm.insert(xvc_path, xvc_md); - } - PathEvent::Update { path, metadata } => { - let xvc_path = XvcPath::new(xvc_root, xvc_root, &path).unwrap(); - let xvc_md = XvcMetadata::from(metadata); - pmm.insert(xvc_path, xvc_md); - } - PathEvent::Delete { path } => { - let xvc_path = XvcPath::new(xvc_root, xvc_root, &path).unwrap(); - let xvc_md = XvcMetadata { - file_type: XvcFileType::Missing, - size: None, - modified: None, - }; - pmm.insert(xvc_path, xvc_md); - } - }; - - loop { - watch!(fs_receiver); - select! { - recv(fs_receiver) -> fs_event => match fs_event { - Ok(Some(fs_event)) => { - handle_fs_event(fs_event); - } - Ok(None) => { - return Ok(()) - } - Err(e) => { - error!("Error in fs_receiver: {:?}", e); - return Err(anyhow!("Error in fs_receiver: {:?}", e).into()) - } - }, - - recv(kill_signal_receiver) -> kill_signal => { - if let Ok(true) = kill_signal { - return Ok(()) - } - }, - } - } -} - fn s_begin_f_init<'a>(s: &BeginState, params: StepStateParams<'a>) -> StateTransition<'a> { if params.run_conditions.never { Ok((s.run_never(), params)) // s_no_need_to_run_f_run_never diff --git a/walker/src/ignore_rules.rs b/walker/src/ignore_rules.rs index a73d6a7ec..c60907d00 100644 --- a/walker/src/ignore_rules.rs +++ b/walker/src/ignore_rules.rs @@ -1,17 +1,10 @@ -use std::cell::RefCell; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; -use globset::Glob; use globset::GlobSet; use itertools::Itertools; -use xvc_logging::watch; -use crate::content_to_patterns; -use crate::GlobPattern; -use crate::PatternEffect; -use crate::Result; -use crate::{build_globset, build_ignore_rules}; +use crate::{build_globset, content_to_patterns, GlobPattern, PatternEffect, Result}; /// Complete set of ignore rules for a directory and its child directories. #[derive(Debug, Clone)] @@ -105,7 +98,7 @@ impl IgnoreRules { Ok(()) } - fn update_ignore(&mut self, new_ignore_patterns: &Vec) -> Result<()> { + fn update_ignore(&mut self, new_ignore_patterns: &[GlobPattern]) -> Result<()> { assert!(new_ignore_patterns .iter() .all(|p| matches!(p.effect, PatternEffect::Ignore)));