Fix edgecase for du on mac
When du encounters a file that cannot be read it logs an error and
continues to analysise the rest of the directory. This behaviour brings
it inline with the original du.
@@ -91,7 +91,9 @@ fn du(mut my_stat: Stat, options: &Options, depth: usize) -> Box<DoubleEndedIter
};
for f in read.into_iter() {
- let entry = crash_if_err!(1, f);
+ match f {
+ Ok(entry) => match fs::symlink_metadata(entry.path()) {
+ Ok(_) => {
let this_stat = Stat::new(entry.path());
if this_stat.is_dir {
futures.push(du(this_stat, options, depth + 1));
@@ -103,6 +105,11 @@ fn du(mut my_stat: Stat, options: &Options, depth: usize) -> Box<DoubleEndedIter
}
}
}
+ Err(error) => show_error!("{}", error),
+ },
+ Err(error) => show_error!("{}", error),
+ }
+ }
}
stats.extend(
