Skip to content

Commit

Permalink
Fixed copy-paste bug in access times.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanMcDonald authored Aug 3, 2019
1 parent f19f7be commit 215b779
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<'dir> File<'dir> {
if self.metadata.modified().unwrap() < UNIX_EPOCH {
return SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
} else {
return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap()
return self.metadata.modified().unwrap().duration_since(UNIX_EPOCH).unwrap()
}
}

Expand All @@ -344,17 +344,17 @@ impl<'dir> File<'dir> {
/// This file’s last accessed timestamp.
/// If the file's time is invalid, assume it was accessed today
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()
} else {
return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap()
return self.metadata.accessed().unwrap().duration_since(UNIX_EPOCH).unwrap()
}
}

/// This file’s created timestamp.
/// If the file's time is invalid, assume it was created today
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()
} else {
return self.metadata.created().unwrap().duration_since(UNIX_EPOCH).unwrap()
Expand Down

0 comments on commit 215b779

Please sign in to comment.