mirror of https://github.com/sharkdp/fd.git
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:
parent
0984ed91ea
commit
1e2db21a77
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue