Skip to content

Commit

Permalink
fix(fs-extra): Don't unwrap in system time converter (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars committed Sep 17, 2024
1 parent cf058d5 commit fadee9d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/fs-extra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ struct Metadata {
}

fn system_time_to_ms(time: std::io::Result<SystemTime>) -> u64 {
time.map(|t| {
let duration_since_epoch = t.duration_since(UNIX_EPOCH).unwrap();
duration_since_epoch.as_millis() as u64
time.map(|time| {
time.duration_since(UNIX_EPOCH)
.map(|t| t.as_millis() as u64)
.unwrap_or_else(|err| err.duration().as_millis() as u64)
})
.unwrap_or_default()
}
Expand Down

0 comments on commit fadee9d

Please sign in to comment.