Skip to content

Commit

Permalink
Count the size of the directories when calculating the size in DirInfo (
Browse files Browse the repository at this point in the history
#3902)

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

* fmt check
  • Loading branch information
hedonihilist committed Aug 7, 2021
1 parent 3884808 commit c9b87c4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/nu-engine/src/filesystem/dir_info.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit c9b87c4

Please sign in to comment.