From fadee9d8bad783b6b1125f6008e2aaf5c55bd663 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Tue, 17 Sep 2024 16:59:58 +0200 Subject: [PATCH] fix(fs-extra): Don't unwrap in system time converter (#1800) --- plugins/fs-extra/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/fs-extra/src/lib.rs b/plugins/fs-extra/src/lib.rs index 621a28bd8..8fa90a132 100644 --- a/plugins/fs-extra/src/lib.rs +++ b/plugins/fs-extra/src/lib.rs @@ -78,9 +78,10 @@ struct Metadata { } fn system_time_to_ms(time: std::io::Result) -> 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() }