Skip to content

Commit fadee9d

Browse files
authored
fix(fs-extra): Don't unwrap in system time converter (#1800)
1 parent cf058d5 commit fadee9d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugins/fs-extra/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ struct Metadata {
7878
}
7979

8080
fn system_time_to_ms(time: std::io::Result<SystemTime>) -> u64 {
81-
time.map(|t| {
82-
let duration_since_epoch = t.duration_since(UNIX_EPOCH).unwrap();
83-
duration_since_epoch.as_millis() as u64
81+
time.map(|time| {
82+
time.duration_since(UNIX_EPOCH)
83+
.map(|t| t.as_millis() as u64)
84+
.unwrap_or_else(|err| err.duration().as_millis() as u64)
8485
})
8586
.unwrap_or_default()
8687
}

0 commit comments

Comments
 (0)