mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
du: Consolidate all "do not print" conditions
All of these conditions should make du just not report the file size individually, but it should still count them into the grand total. In the case of the `--threshold` option, this was actually implemented incorrectly before, as it would report size 0 for files that did not match the threshold.
This commit is contained in:
parent
e4cdc7f685
commit
480ba792e3
Notes:
sideshowbarker
2024-07-17 08:37:03 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/480ba792e3 Pull-request: https://github.com/SerenityOS/serenity/pull/14668 Reviewed-by: https://github.com/IdanHo
@ -165,15 +165,14 @@ ErrorOr<u64> print_space_usage(String const& path, DuOption const& du_option, si
|
||||
size += path_stat.st_size;
|
||||
}
|
||||
|
||||
if (inside_dir && !du_option.all && !is_directory)
|
||||
bool is_beyond_depth = current_depth > du_option.max_depth;
|
||||
bool is_inner_file = inside_dir && !is_directory;
|
||||
bool is_outside_threshold = (du_option.threshold > 0 && size < static_cast<u64>(du_option.threshold)) || (du_option.threshold < 0 && size > static_cast<u64>(-du_option.threshold));
|
||||
|
||||
// All of these still count towards the full size, they are just not reported on individually.
|
||||
if (is_beyond_depth || (is_inner_file && !du_option.all) || is_outside_threshold)
|
||||
return size;
|
||||
|
||||
if ((du_option.threshold > 0 && size < static_cast<u64>(du_option.threshold)) || (du_option.threshold < 0 && size > static_cast<u64>(-du_option.threshold)))
|
||||
return { 0 };
|
||||
|
||||
if (current_depth > du_option.max_depth)
|
||||
return { size };
|
||||
|
||||
if (du_option.human_readable) {
|
||||
out("{}", human_readable_size(size));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user