Count the size of the directories when calculating the size in DirInfo (#3902)

* take dir entry size into consideration when calculting the size of a directory in DirInfo

* fmt check
This commit is contained in:
hedonihilist 2021-08-08 01:50:02 +08:00 committed by GitHub
parent 38848082ae
commit c9b87c4c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,14 @@ impl DirInfo {
path,
};
match std::fs::metadata(&s.path) {
Ok(d) => {
s.size = d.len(); // dir entry size
s.blocks = file_real_size_fast(&s.path, &d).ok().unwrap_or(0);
}
Err(e) => s = s.add_error(e.into()),
};
match std::fs::read_dir(&s.path) {
Ok(d) => {
for f in d {