Handle min-depth for broken symlink

Introduced a comparison function to handle min-depth
check for broken symlinks instead of `depth`
This commit is contained in:
theirix 2022-10-07 22:01:00 +03:00
parent 0984ed91ea
commit 1e2db21a77
2 changed files with 6 additions and 4 deletions

View File

@ -82,10 +82,12 @@ impl DirEntry {
.as_ref()
}
pub fn depth(&self) -> Option<usize> {
/// Returns true if the entry has the depth greater or equal compared to `depth`
pub fn deeper(&self, depth: usize) -> bool {
match &self.inner {
DirEntryInner::Normal(e) => Some(e.depth()),
DirEntryInner::BrokenSymlink(_) => None,
DirEntryInner::Normal(e) => e.depth() >= depth,
// broken symlink passes match if it is just longer thatn the `depth`
DirEntryInner::BrokenSymlink(p) => p.components().count() - 1 >= depth,
}
}
}

View File

@ -441,7 +441,7 @@ fn spawn_senders(
};
if let Some(min_depth) = config.min_depth {
if entry.depth().map_or(true, |d| d < min_depth) {
if !entry.deeper(min_depth) {
return ignore::WalkState::Continue;
}
}