mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Feature/Bugfix: Allow multiple regexs to be used
The -e and -v flags allow multiple values. Before values after the first were ignored. This change allows the user to specify multiple regexs and have them all applied.
This commit is contained in:
+5
-5
@@ -20,8 +20,8 @@ use crate::platform::get_metadata;
|
||||
|
||||
pub struct WalkData {
|
||||
pub ignore_directories: HashSet<PathBuf>,
|
||||
pub filter_regex: Option<Regex>,
|
||||
pub invert_filter_regex: Option<Regex>,
|
||||
pub filter_regex: Vec<Regex>,
|
||||
pub invert_filter_regex: Vec<Regex>,
|
||||
pub allowed_filesystems: HashSet<u64>,
|
||||
pub use_apparent_size: bool,
|
||||
pub by_filecount: bool,
|
||||
@@ -90,15 +90,15 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
// Keeping `walk_data.filter_regex.is_some()` is important for performance reasons, it stops unnecessary work
|
||||
if walk_data.filter_regex.is_some()
|
||||
// Keeping `walk_data.filter_regex.is_empty()` is important for performance reasons, it stops unnecessary work
|
||||
if !walk_data.filter_regex.is_empty()
|
||||
&& entry.path().is_file()
|
||||
&& is_filtered_out_due_to_regex(&walk_data.filter_regex, &entry.path())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if walk_data.invert_filter_regex.is_some()
|
||||
if !walk_data.invert_filter_regex.is_empty()
|
||||
&& entry.path().is_file()
|
||||
&& is_filtered_out_due_to_invert_regex(&walk_data.invert_filter_regex, &entry.path())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user