mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-19 02:10:34 +01:00
Extract entry extension only when there is an extension filter
This commit is contained in:
parent
83db8673cf
commit
32a321aafd
1 changed files with 5 additions and 8 deletions
|
@ -307,14 +307,11 @@ fn scan(root: &Path, pattern: Arc<Regex>, base: &Path, config: Arc<FdOptions>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out unwanted extensions.
|
// Filter out unwanted extensions.
|
||||||
match (&config.extension, entry.path().extension()) {
|
if let Some(ref filter_ext) = config.extension {
|
||||||
(&None, _) => (),
|
let entry_ext = entry.path().extension().map(|e| e.to_string_lossy().to_lowercase());
|
||||||
(&Some(_), None) => return ignore::WalkState::Continue,
|
if entry_ext.map_or(false, |ext| ext != *filter_ext) {
|
||||||
(&Some(ref e1), Some(e2)) => {
|
|
||||||
if e1 != &e2.to_string_lossy().to_lowercase() {
|
|
||||||
return ignore::WalkState::Continue;
|
return ignore::WalkState::Continue;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let path_rel_buf = match fshelper::path_relative_from(entry.path(), &*base) {
|
let path_rel_buf = match fshelper::path_relative_from(entry.path(), &*base) {
|
||||||
|
|
Loading…
Reference in a new issue