Kaynağa Gözat

feat: symlinks report their target's valid size

Co-authored-by: Luc Ritchie <luc.ritchie@gmail.com>
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
Luc Ritchie 3 yıl önce
ebeveyn
işleme
519829f40c
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  1. 6 0
      src/fs/file.rs

+ 6 - 0
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
         }