Fixed copy-paste bug in access times.

This commit is contained in:
Brennan McDonald 2019-08-03 11:07:16 -07:00 committed by GitHub
parent f19f7be726
commit 215b779d35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -332,7 +332,7 @@ impl<'dir> File<'dir> {
if self.metadata.modified().unwrap() < UNIX_EPOCH { if self.metadata.modified().unwrap() < UNIX_EPOCH {
return SystemTime::now().duration_since(UNIX_EPOCH).unwrap() return SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
} else { } else {
return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap() return self.metadata.modified().unwrap().duration_since(UNIX_EPOCH).unwrap()
} }
} }
@ -344,17 +344,17 @@ impl<'dir> File<'dir> {
/// This files last accessed timestamp. /// This files last accessed timestamp.
/// If the file's time is invalid, assume it was accessed today /// If the file's time is invalid, assume it was accessed today
pub fn accessed_time(&self) -> Duration { pub fn accessed_time(&self) -> Duration {
if self.metadata.modified().unwrap() < UNIX_EPOCH{ if self.metadata.accessed().unwrap() < UNIX_EPOCH{
return SystemTime::now().duration_since(UNIX_EPOCH).unwrap() return SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
} else { } else {
return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap() return self.metadata.accessed().unwrap().duration_since(UNIX_EPOCH).unwrap()
} }
} }
/// This files created timestamp. /// This files created timestamp.
/// If the file's time is invalid, assume it was created today /// If the file's time is invalid, assume it was created today
pub fn created_time(&self) -> Duration { pub fn created_time(&self) -> Duration {
if self.metadata.modified().unwrap() < UNIX_EPOCH { if self.metadata.created().unwrap() < UNIX_EPOCH {
return SystemTime::now().duration_since(UNIX_EPOCH).unwrap() return SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
} else { } else {
return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap() return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap()