From b1c466416fa662ee6e50209d94f82551ca1a8e5b Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Thu, 14 Dec 2023 00:06:07 +0000 Subject: [PATCH] hack --- src/main.rs | 27 ++++++++++++++++++--------- tests/test_flags.rs | 7 ++++++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7c7b12af..6a9f347f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ use display::InitialDisplayData; use filter::AggregateData; use progress::PIndicator; use progress::ORDERING; +use regex::Error; use std::collections::HashSet; use std::fs::read_to_string; use std::panic; @@ -143,17 +144,25 @@ fn main() { None => vec![], }; - let ignore_directories_from_file = match options.get_one::("ignore_all_in_file") { + let ignore_from_file_result = match options.get_one::("ignore_all_in_file") { Some(val) => { read_to_string(val) .unwrap() .lines() - .map(PathBuf::from) - .collect::>() + .map(Regex::new) + .collect::>>() } None => vec![], }; - let ignored:Vec = ignore_directories.into_iter().chain(ignore_directories_from_file.into_iter()).collect(); + let ignore_from_file = ignore_from_file_result + .into_iter() + .filter_map(|x| x.ok()) + .collect::>(); + + let invert_filter_regexs = invert_filter_regexs + .into_iter() + .chain(ignore_from_file) + .collect::>(); let by_filecount = options.get_flag("by_filecount"); let limit_filesystem = options.get_flag("limit_filesystem"); @@ -164,12 +173,10 @@ fn main() { .then(|| get_filesystem_devices(simplified_dirs.iter())) .unwrap_or_default(); - println!("{:?}", ignored); - let ignored_full_path: HashSet = ignored + let ignored_full_path: HashSet = ignore_directories .into_iter() .flat_map(|x| simplified_dirs.iter().map(move |d| d.join(&x))) .collect(); - println!("{:?}", ignored_full_path); let iso = config.get_iso(&options); @@ -244,7 +251,9 @@ fn init_rayon(stack_size: &Option) { if cfg!(target_pointer_width = "64") { let result = panic::catch_unwind(|| { match stack_size { - Some(n) => rayon::ThreadPoolBuilder::new().stack_size(*n).build_global(), + Some(n) => rayon::ThreadPoolBuilder::new() + .stack_size(*n) + .build_global(), None => { let large_stack = usize::pow(1024, 3); let mut s = System::new(); @@ -266,4 +275,4 @@ fn init_rayon(stack_size: &Option) { eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1") } } -} \ No newline at end of file +} diff --git a/tests/test_flags.rs b/tests/test_flags.rs index e107f44b..199ac0e9 100644 --- a/tests/test_flags.rs +++ b/tests/test_flags.rs @@ -77,7 +77,12 @@ pub fn test_ignore_dir() { #[test] pub fn test_ignore_all_in_file() { - let output = build_command(vec!["-c", "-I", "tests/test_dir_hidden_entries/.hidden_file", "tests/test_dir_hidden_entries/"]); + let output = build_command(vec![ + "-c", + "-I", + "tests/test_dir_hidden_entries/.hidden_file", + "tests/test_dir_hidden_entries/", + ]); assert!(output.contains(" test_dir_hidden_entries")); assert!(!output.contains(".secret")); }