mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 14:07:46 +00:00
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.
This commit is contained in:
parent
fa0b7ed41b
commit
f0e25e5537
1 changed files with 17 additions and 10 deletions
27
src/du/du.rs
27
src/du/du.rs
|
@ -91,16 +91,23 @@ 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);
|
||||
let this_stat = Stat::new(entry.path());
|
||||
if this_stat.is_dir {
|
||||
futures.push(du(this_stat, options, depth + 1));
|
||||
} else {
|
||||
my_stat.size += this_stat.size;
|
||||
my_stat.blocks += this_stat.blocks;
|
||||
if options.all {
|
||||
stats.push(this_stat);
|
||||
}
|
||||
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));
|
||||
} else {
|
||||
my_stat.size += this_stat.size;
|
||||
my_stat.blocks += this_stat.blocks;
|
||||
if options.all {
|
||||
stats.push(this_stat);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(error) => show_error!("{}", error),
|
||||
},
|
||||
Err(error) => show_error!("{}", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue