Compare commits

...

2 commits

Author SHA1 Message Date
cf0aa33314
refactor: remove useless prints 2024-12-30 16:36:26 +02:00
e952225ec6
refactor: handle errors 2024-12-30 16:32:05 +02:00

View file

@ -91,10 +91,9 @@ fn main() {
let mut thread_pool: Vec<thread::JoinHandle<()>> = Vec::new();
for selection in actual_selection {
// TODO: forget the assumption that the user won't try to sort like 100 dirs at the same
// time
let thread = thread::spawn(move || {
let _ = sort_files(selection, false); // TODO: handle errors
let thread = thread::spawn(move || match sort_files(selection, false) {
Ok(_) => {}
Err(err) => eprintln!("{}", err),
});
thread_pool.push(thread);
@ -107,16 +106,12 @@ fn main() {
// TODO: implement recuriveness
fn sort_files(selection: String, _recursive: bool) -> Result<(), Box<dyn std::error::Error>> {
println!("Sorting {}", selection);
let search_path = CONFIG
.get()
.and_then(|config| config.sources.get(&selection))
.cloned()
.unwrap();
println!("Searching in {}", search_path.display());
let dir = fs::read_dir(search_path)?;
let file_types = [