mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
refactor: extract function
This commit is contained in:
+39
-34
@@ -295,40 +295,8 @@ fn main() {
|
|||||||
// Must have stopped indicator before we print to stderr
|
// Must have stopped indicator before we print to stderr
|
||||||
indicator.stop();
|
indicator.stop();
|
||||||
|
|
||||||
let final_errors = walk_data.errors.lock().unwrap();
|
let print_errors = config.get_print_errors(&options);
|
||||||
if !final_errors.file_not_found.is_empty() {
|
print_any_errors(print_errors, walk_data.errors);
|
||||||
let err = final_errors
|
|
||||||
.file_not_found
|
|
||||||
.iter()
|
|
||||||
.map(|a| a.as_ref())
|
|
||||||
.collect::<Vec<&str>>()
|
|
||||||
.join(", ");
|
|
||||||
eprintln!("No such file or directory: {}", err);
|
|
||||||
}
|
|
||||||
if !final_errors.no_permissions.is_empty() {
|
|
||||||
if config.get_print_errors(&options) {
|
|
||||||
let err = final_errors
|
|
||||||
.no_permissions
|
|
||||||
.iter()
|
|
||||||
.map(|a| a.as_ref())
|
|
||||||
.collect::<Vec<&str>>()
|
|
||||||
.join(", ");
|
|
||||||
eprintln!("Did not have permissions for directories: {}", err);
|
|
||||||
} else {
|
|
||||||
eprintln!(
|
|
||||||
"Did not have permissions for all directories (add --print-errors to see errors)"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !final_errors.unknown_error.is_empty() {
|
|
||||||
let err = final_errors
|
|
||||||
.unknown_error
|
|
||||||
.iter()
|
|
||||||
.map(|a| a.as_ref())
|
|
||||||
.collect::<Vec<&str>>()
|
|
||||||
.join(", ");
|
|
||||||
eprintln!("Unknown Error: {}", err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(root_node) = tree {
|
if let Some(root_node) = tree {
|
||||||
if config.get_output_json(&options) {
|
if config.get_output_json(&options) {
|
||||||
@@ -359,6 +327,43 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_any_errors(print_errors: bool, errors: Arc<Mutex<RuntimeErrors>>) {
|
||||||
|
let final_errors = errors.lock().unwrap();
|
||||||
|
if !final_errors.file_not_found.is_empty() {
|
||||||
|
let err = final_errors
|
||||||
|
.file_not_found
|
||||||
|
.iter()
|
||||||
|
.map(|a| a.as_ref())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.join(", ");
|
||||||
|
eprintln!("No such file or directory: {}", err);
|
||||||
|
}
|
||||||
|
if !final_errors.no_permissions.is_empty() {
|
||||||
|
if print_errors {
|
||||||
|
let err = final_errors
|
||||||
|
.no_permissions
|
||||||
|
.iter()
|
||||||
|
.map(|a| a.as_ref())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.join(", ");
|
||||||
|
eprintln!("Did not have permissions for directories: {}", err);
|
||||||
|
} else {
|
||||||
|
eprintln!(
|
||||||
|
"Did not have permissions for all directories (add --print-errors to see errors)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !final_errors.unknown_error.is_empty() {
|
||||||
|
let err = final_errors
|
||||||
|
.unknown_error
|
||||||
|
.iter()
|
||||||
|
.map(|a| a.as_ref())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.join(", ");
|
||||||
|
eprintln!("Unknown Error: {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn init_rayon(stack_size: &Option<usize>, threads: &Option<usize>) {
|
fn init_rayon(stack_size: &Option<usize>, threads: &Option<usize>) {
|
||||||
// Rayon seems to raise this error on 32-bit builds
|
// Rayon seems to raise this error on 32-bit builds
|
||||||
// The global thread pool has not been initialized.: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }
|
// The global thread pool has not been initialized.: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }
|
||||||
|
|||||||
Reference in New Issue
Block a user