Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iesahin committed Dec 30, 2023
1 parent b765cf2 commit 4aa404b
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 76 deletions.
2 changes: 1 addition & 1 deletion config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 1 addition & 7 deletions core/src/util/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl XvcPathMetadataProvider {
Ok(())
}

/// Return all paths from the disk specified with glob
pub fn glob_paths(&self, glob: &str) -> Result<XvcPathMetadataMap> {
watch!(glob);
self.update_with_glob(glob)?;
Expand Down Expand Up @@ -301,12 +302,6 @@ pub fn compiled_glob(pipeline_rundir: &Path, glob: &str) -> Result<glob::Pattern
.map_err(|source| Error::GlobPatternError { source })
}

/// Returns a compiled [Regex] from `path`.
#[cached(result = true)]
pub fn compiled_regex(pat: String) -> Result<Regex> {
Regex::new(&pat).map_err(|source| Error::RegexError { source })
}

/// Returns all _non-ignored_ paths described with `glob` under `root_dir`
#[cached(
type = "UnboundCache<String, XvcPathMetadataMap>",
Expand All @@ -315,7 +310,6 @@ pub fn compiled_regex(pat: String) -> Result<Regex> {
result = true
)]
pub fn glob_paths(
xvc_root: &XvcRoot,
pmp: &XvcPathMetadataProvider,
root_dir: &XvcPath,
glob: &str,
Expand Down
2 changes: 1 addition & 1 deletion ecs/src/ecs/hstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl<T: PartialEq> HStore<T> {
/// Returns the first entity matched with [Self::entities_for]
pub fn entity_by_value(&self, value: &T) -> Option<XvcEntity> {
match self.entities_for(value) {
Some(vec_e) => vec_e.get(0).copied(),
Some(vec_e) => vec_e.first().copied(),
None => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion ecs/src/ecs/r11store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ where
pub fn entity_by_right(&self, right_element: &U) -> Option<XvcEntity> {
match self.right.entities_for(right_element) {
None => None,
Some(vec_e) => vec_e.get(0).copied(),
Some(vec_e) => vec_e.first().copied(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion ecs/src/ecs/xvcstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ where
/// Returns the first entity matched with [Self::entities_for]
pub fn entity_by_value(&self, value: &T) -> Option<XvcEntity> {
match self.entities_for(value) {
Some(vec_e) => vec_e.get(0).copied(),
Some(vec_e) => vec_e.first().copied(),
None => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion file/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub fn recheck_from_cache(
recheck_method: RecheckMethod,
ignore_writer: &Sender<IgnoreOp>,
) -> 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);
Expand Down
2 changes: 1 addition & 1 deletion pipeline/src/pipeline/deps/glob_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl GlobItemsDep {
pmp: &XvcPathMetadataProvider,
) -> Result<GlobItemsDep> {
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,
Expand Down
2 changes: 1 addition & 1 deletion pipeline/src/pipeline/deps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
53 changes: 0 additions & 53 deletions pipeline/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,59 +781,6 @@ fn step_state_handler(step_e: XvcEntity, params: StepThreadParams) -> Result<()>
}
}

fn update_pmp(
xvc_root: &XvcRoot,
fs_receiver: Receiver<Option<PathEvent>>,
pmm: &mut XvcPathMetadataMap,
kill_signal_receiver: Receiver<bool>,
) -> 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
Expand Down
11 changes: 2 additions & 9 deletions walker/src/ignore_rules.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -105,7 +98,7 @@ impl IgnoreRules {

Ok(())
}
fn update_ignore(&mut self, new_ignore_patterns: &Vec<GlobPattern>) -> Result<()> {
fn update_ignore(&mut self, new_ignore_patterns: &[GlobPattern]) -> Result<()> {
assert!(new_ignore_patterns
.iter()
.all(|p| matches!(p.effect, PatternEffect::Ignore)));
Expand Down

0 comments on commit 4aa404b

Please sign in to comment.