Skip to content

Commit

Permalink
hack
Browse files Browse the repository at this point in the history
  • Loading branch information
bootandy committed Dec 14, 2023
1 parent 55cbef6 commit b1c4664
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,17 +144,25 @@ fn main() {
None => vec![],
};

let ignore_directories_from_file = match options.get_one::<String>("ignore_all_in_file") {
let ignore_from_file_result = match options.get_one::<String>("ignore_all_in_file") {
Some(val) => {
read_to_string(val)
.unwrap()
.lines()
.map(PathBuf::from)
.collect::<Vec<PathBuf>>()
.map(Regex::new)
.collect::<Vec<Result<Regex, Error>>>()
}
None => vec![],
};
let ignored:Vec<PathBuf> = 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::<Vec<Regex>>();

let invert_filter_regexs = invert_filter_regexs
.into_iter()
.chain(ignore_from_file)
.collect::<Vec<Regex>>();

let by_filecount = options.get_flag("by_filecount");
let limit_filesystem = options.get_flag("limit_filesystem");
Expand All @@ -164,12 +173,10 @@ fn main() {
.then(|| get_filesystem_devices(simplified_dirs.iter()))
.unwrap_or_default();

println!("{:?}", ignored);
let ignored_full_path: HashSet<PathBuf> = ignored
let ignored_full_path: HashSet<PathBuf> = 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);

Expand Down Expand Up @@ -244,7 +251,9 @@ fn init_rayon(stack_size: &Option<usize>) {
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();
Expand All @@ -266,4 +275,4 @@ fn init_rayon(stack_size: &Option<usize>) {
eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1")
}
}
}
}
7 changes: 6 additions & 1 deletion tests/test_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down

0 comments on commit b1c4664

Please sign in to comment.