Merge pull request #6840 from jesseschalken/reuse-metadata-instead-of-path-is-dir

du: Reuse existing metadata instead of calling path.is_dir() again
This commit is contained in:
Sylvestre Ledru 2024-12-02 20:41:35 +01:00 committed by GitHub
commit 763306ccc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,