do not calculate total directory size unless it will be displayed

This commit is contained in:
Juan 2022-04-08 21:57:08 -07:00 committed by Wei Zhang
parent 23a11de5df
commit dd2ef0aad6
2 changed files with 6 additions and 1 deletions

View file

@ -124,7 +124,8 @@ impl Core {
meta_list.push(meta);
};
}
if self.flags.total_size.0 {
// Only calculate the total size of a directory if it will be displayed
if self.flags.total_size.0 && self.flags.blocks.displays_size() {
for meta in &mut meta_list.iter_mut() {
meta.calculate_total_size();
}

View file

@ -151,6 +151,10 @@ impl Blocks {
}
}
pub fn displays_size(&self) -> bool {
self.0.contains(&Block::Size)
}
/// Tnserts a [Block] of variant [INode](Block::Context), if `self` does not already contain a
/// [Block] of that variant. The positioning will be best-effort approximation of coreutils
/// ls position for a security context