From 61b5c8c4c4a3fdf086e9819b4cd5ca7264a3c622 Mon Sep 17 00:00:00 2001 From: Luc Ritchie Date: Fri, 20 May 2022 03:30:35 -0400 Subject: [PATCH] Make symlinks report their target's size, if valid --- src/fs/file.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fs/file.rs b/src/fs/file.rs index ea83f08b..6b0b0e36 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -315,6 +315,12 @@ impl<'dir> File<'dir> { /// Block and character devices return their device IDs, because they /// usually just have a file size of zero. pub fn size(&self) -> f::Size { + if self.is_link() { + let target = self.link_target(); + if let FileTarget::Ok(target) = target { + return target.size(); + } + } if self.is_directory() { f::Size::None }