mirror of
https://github.com/nivekuil/rip
synced 2024-11-22 11:43:20 +00:00
Fix panic on inspecting small files
This commit is contained in:
parent
e0d48f5aca
commit
b5cd8615c7
2 changed files with 8 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -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])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue