From 4172ed03f0909c97ed3b2f49f3e93a0e5265f75e Mon Sep 17 00:00:00 2001 From: sharkdp Date: Wed, 25 Apr 2018 08:25:02 +0200 Subject: [PATCH] Do not include non-files when using --size --- src/walk.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/walk.rs b/src/walk.rs index d92cca6..17e3a58 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -249,16 +249,22 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { } // 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 let Ok(metadata) = entry_path.metadata() { - let file_size = metadata.len(); - if config - .size_constraints - .iter() - .any(|sc| !sc.is_within(file_size)) - { + if config.size_constraints.len() > 0 { + if entry_path.is_file() { + if let Ok(metadata) = entry_path.metadata() { + let file_size = metadata.len(); + if config + .size_constraints + .iter() + .any(|sc| !sc.is_within(file_size)) + { + return ignore::WalkState::Continue; + } + } else { return ignore::WalkState::Continue; } + } else { + return ignore::WalkState::Continue; } }