diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -32,7 +32,7 @@ //! ~~~ use serde::Serialize; -use std::fs::Metadata; +use std::fs::symlink_metadata; use std::os::linux::fs::MetadataExt; use std::path::{Path, PathBuf}; @@ -57,8 +57,9 @@ impl ManifestEntry { /// caller. This function doesn't query the system for it. /// /// The structure can be serialized using serde. - pub fn new(path: &Path, m: Metadata) -> Self { - Self { + pub fn new(path: &Path) -> std::io::Result<Self> { + let m = symlink_metadata(path)?; + Ok(Self { path: path.to_path_buf(), atime: m.st_atime(), atime_nsec: m.st_atime_nsec(), @@ -67,7 +68,7 @@ impl ManifestEntry { mtime_nsec: m.st_mtime_nsec(), nlink: m.st_nlink(), size: if m.is_dir() { None } else { Some(m.st_size()) }, - } + }) } } |