From 6487347bc6d212edb72d332844b49701627e6641 Mon Sep 17 00:00:00 2001 From: Jesse Schalken Date: Mon, 28 Oct 2024 20:25:46 +1100 Subject: [PATCH] Reuse existing metadata instead of calling path.is_dir() again --- src/uu/du/src/du.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 2d36679f0..d4bec77ef 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -171,7 +171,7 @@ impl Stat { Ok(Self { path: path.to_path_buf(), is_dir: metadata.is_dir(), - size: if path.is_dir() { 0 } else { metadata.len() }, + size: if metadata.is_dir() { 0 } else { metadata.len() }, blocks: metadata.blocks(), inodes: 1, inode: Some(file_info), @@ -189,7 +189,7 @@ impl Stat { Ok(Self { path: path.to_path_buf(), is_dir: metadata.is_dir(), - size: if path.is_dir() { 0 } else { metadata.len() }, + size: if metadata.is_dir() { 0 } else { metadata.len() }, blocks: size_on_disk / 1024 * 2, inodes: 1, inode: file_info,