Skip to content

Commit

Permalink
du: Don't fail immediately when directory can't be read (SerenityOS#8719
Browse files Browse the repository at this point in the history
)
  • Loading branch information
luk1337 committed Jul 13, 2021
1 parent 77795b2 commit 334499a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Userland/Utilities/du.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ int print_space_usage(const String& path, const DuOption& du_option, int max_dep
return 1;
}

int ret = 0;

if (--max_depth >= 0 && S_ISDIR(path_stat.st_mode)) {
auto di = Core::DirIterator(path, Core::DirIterator::SkipParentAndBaseDir);
if (di.has_error()) {
warnln("DirIterator: {}", di.error_string());
return 1;
warnln("du: cannot read directory '{}': {}", path, di.error_string());
ret = 1;
}
while (di.has_next()) {
const auto child_path = di.next_full_path();
Expand Down Expand Up @@ -193,5 +195,5 @@ int print_space_usage(const String& path, const DuOption& du_option, int max_dep
outln("\t{}\t{}", formatted_time, path);
}

return 0;
return ret;
}

0 comments on commit 334499a

Please sign in to comment.