diff --git a/src/main.rs b/src/main.rs index bc4a85d..3d5e8b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -183,8 +183,9 @@ Send files to the graveyard (/tmp/.graveyard) instead of unlinking them.") // Print the first few top-level files in the directory for entry in WalkDir::new(source) .min_depth(1).max_depth(1).into_iter() + .filter_map(|entry| entry.ok()) .take(FILES_TO_INSPECT) { - println!("{}", entry.unwrap().path().display()); + println!("{}", entry.path().display()); } } else { println!("{}: file, {}", target, diff --git a/src/util.rs b/src/util.rs index c9692c1..aa402d6 100644 --- a/src/util.rs +++ b/src/util.rs @@ -35,7 +35,10 @@ fn humanize_bytes(bytes: u64) -> String { let pair = values.iter() .enumerate() .take_while(|x| bytes as usize / (1000 as usize).pow(x.0 as u32) > 10) - .last() - .unwrap(); - format!("{} {}", bytes as usize / (1000 as usize).pow(pair.0 as u32), pair.1) + .last(); + if let Some(p) = pair { + format!("{} {}", bytes as usize / (1000 as usize).pow(p.0 as u32), p.1) + } else { + format!("{} {}", bytes, values[0]) + } }