summaryrefslogtreecommitdiffstats
path: root/src/tree
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-02-03 21:06:51 +0100
committerCanop <cano.petrole@gmail.com>2021-02-03 21:06:51 +0100
commitde3e3122a136659f32a3fdd37a2f29f84579c957 (patch)
tree46fa2459363cf9d74afcc9cc56b48eeabde286cf /src/tree
parentcc3b2c04521c6e5886f0bb2f56f1ca80a2b8e05a (diff)
ignore special paths with "no-enter" or "hide" in sums
Fix #331
Diffstat (limited to 'src/tree')
-rw-r--r--src/tree/special_path.rs13
-rw-r--r--src/tree/tree.rs4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/tree/special_path.rs b/src/tree/special_path.rs
index a98cc75..b8674c1 100644
--- a/src/tree/special_path.rs
+++ b/src/tree/special_path.rs
@@ -53,12 +53,11 @@ impl<'de> Deserialize<'de> for Glob {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>
{
- let s = String::deserialize(deserializer)?;
- glob::Pattern::new(&s)
- .map_err(|e| D::Error::custom(format!("invalid glob pattern {:?} : {:?}", s, e)))
- .map(|pattern| Glob { pattern })
+ let s = String::deserialize(deserializer)?;
+ glob::Pattern::new(&s)
+ .map_err(|e| D::Error::custom(format!("invalid glob pattern {:?} : {:?}", s, e)))
+ .map(|pattern| Glob { pattern })
}
-
}
impl SpecialPath {
@@ -68,6 +67,10 @@ impl SpecialPath {
handling,
}
}
+ pub fn can_have_matches_in(&self, path: &Path) -> bool {
+ path.to_str()
+ .map_or(false, |p| self.pattern.as_str().starts_with(p))
+ }
}
impl SpecialPathList for &[SpecialPath] {
diff --git a/src/tree/tree.rs b/src/tree/tree.rs
index 2b1f2b0..0404c75 100644
--- a/src/tree/tree.rs
+++ b/src/tree/tree.rs
@@ -366,12 +366,12 @@ impl Tree {
///
/// To compute the size of all of them, this should be called until
/// has_dir_missing_sum returns false
- pub fn fetch_some_missing_dir_sum(&mut self, dam: &Dam) {
+ pub fn fetch_some_missing_dir_sum(&mut self, dam: &Dam, con: &AppContext) {
// we prefer to compute the root directory last: its computation
// is faster when its first level children are already computed
for i in (0..self.lines.len()).rev() {
if self.lines[i].sum.is_none() && self.lines[i].line_type == TreeLineType::Dir {
- self.lines[i].sum = FileSum::from_dir(&self.lines[i].path, dam);
+ self.lines[i].sum = FileSum::from_dir(&self.lines[i].path, dam, con);
self.sort_siblings();
return;
}