mirror of
https://github.com/astro/deadnix.git
synced 2024-11-28 01:44:32 +03:00
main: move --exclude path canonicalization from filtering out to initialization
This commit is contained in:
parent
de76ad0720
commit
a9f858648d
@ -120,12 +120,13 @@ fn main() {
|
|||||||
entry.file_name().to_str()
|
entry.file_name().to_str()
|
||||||
.map_or(false, |s| s == "." || s == ".." || ! s.starts_with('.'))
|
.map_or(false, |s| s == "." || s == ".." || ! s.starts_with('.'))
|
||||||
};
|
};
|
||||||
let is_included: Box<dyn Fn(&String) -> bool> = if let Some(excludes) = matches.get_many("EXCLUDES") {
|
let is_included: Box<dyn Fn(&String) -> bool> = if let Some(excludes) = matches.get_many::<String>("EXCLUDES") {
|
||||||
let excludes = excludes.cloned().collect::<HashSet<String>>();
|
let excludes = excludes.filter_map(|exclude|
|
||||||
|
Path::new(exclude).canonicalize().ok()
|
||||||
|
).collect::<HashSet<_>>();
|
||||||
Box::new(move |s| {
|
Box::new(move |s| {
|
||||||
let s = Path::new(s).canonicalize().unwrap();
|
let s = Path::new(s).canonicalize().unwrap();
|
||||||
!excludes.iter().any(|exclude| {
|
! excludes.iter().any(|exclude| {
|
||||||
let exclude = Path::new(exclude).canonicalize().unwrap();
|
|
||||||
s.starts_with(&exclude)
|
s.starts_with(&exclude)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user