Support filesystems (e.g. ZFS) that don't expose a creation time
continuous-integration/drone the build was successful Details

This commit is contained in:
Olivier 'reivilibre' 2022-02-07 19:06:50 +00:00
parent 912f8c4fbf
commit 7fbe51db68
3 changed files with 6 additions and 5 deletions

View File

@ -162,8 +162,8 @@ pub struct FileMetadata {
pub atime: SystemTime,
/// Time of last modification
pub mtime: SystemTime,
/// Time of last change
pub ctime: SystemTime,
/// Time of last change. Not all filesystems have this.
pub ctime: Option<SystemTime>,
// /// Time of creation (macOS only)
// pub crtime: SystemTime,
/// Kind of file (directory, file, pipe, etc)

View File

@ -1,5 +1,6 @@
use crate::messages::{FileKind, FileMetadata};
use fuser::{FileAttr, FileType};
use std::time::SystemTime;
impl From<FileType> for FileKind {
fn from(filetype: FileType) -> Self {
@ -37,8 +38,8 @@ impl Into<FileAttr> for FileMetadata {
blocks: self.blocks,
atime: self.atime,
mtime: self.mtime,
ctime: self.ctime,
crtime: self.ctime,
ctime: self.ctime.unwrap_or(SystemTime::UNIX_EPOCH),
crtime: self.ctime.unwrap_or(SystemTime::UNIX_EPOCH),
kind: self.kind.into(),
perm: self.perm,
nlink: self.nlink,

View File

@ -240,7 +240,7 @@ impl FileAccess {
blocks: metadata.blocks(),
atime: metadata.accessed().unwrap(),
mtime: metadata.modified().unwrap(),
ctime: metadata.created().unwrap(),
ctime: metadata.created().ok(),
kind: metadata.file_type().into(),
perm: metadata.permissions().mode() as u16,
nlink: metadata.nlink() as u32,