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, pub atime: SystemTime,
/// Time of last modification /// Time of last modification
pub mtime: SystemTime, pub mtime: SystemTime,
/// Time of last change /// Time of last change. Not all filesystems have this.
pub ctime: SystemTime, pub ctime: Option<SystemTime>,
// /// Time of creation (macOS only) // /// Time of creation (macOS only)
// pub crtime: SystemTime, // pub crtime: SystemTime,
/// Kind of file (directory, file, pipe, etc) /// Kind of file (directory, file, pipe, etc)

View File

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

View File

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