mirror of https://github.com/sharkdp/fd.git
Do not include non-files when using --size
This commit is contained in:
parent
0bbc7f5219
commit
4172ed03f0
22
src/walk.rs
22
src/walk.rs
|
@ -249,16 +249,22 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out unwanted sizes if it is a file and we have been given size constraints.
|
// Filter out unwanted sizes if it is a file and we have been given size constraints.
|
||||||
if config.size_constraints.len() > 0 && entry_path.is_file() {
|
if config.size_constraints.len() > 0 {
|
||||||
if let Ok(metadata) = entry_path.metadata() {
|
if entry_path.is_file() {
|
||||||
let file_size = metadata.len();
|
if let Ok(metadata) = entry_path.metadata() {
|
||||||
if config
|
let file_size = metadata.len();
|
||||||
.size_constraints
|
if config
|
||||||
.iter()
|
.size_constraints
|
||||||
.any(|sc| !sc.is_within(file_size))
|
.iter()
|
||||||
{
|
.any(|sc| !sc.is_within(file_size))
|
||||||
|
{
|
||||||
|
return ignore::WalkState::Continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return ignore::WalkState::Continue;
|
return ignore::WalkState::Continue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return ignore::WalkState::Continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue