From bed197d16558fec733267773094a32ca500e9128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Sun, 4 Jun 2023 13:54:06 -0300 Subject: [PATCH] fix: handle Zip when modified times are missing --- src/archive/zip.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index b331b54c1..01e6d25dc 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -261,14 +261,15 @@ fn get_last_modified_time(file: &fs::File) -> DateTime { } fn set_last_modified_time(zip_file: &ZipFile, path: &Path) -> crate::Result<()> { - let modification_time_in_seconds = zip_file - .last_modified() - .to_time() - .expect("Zip archive contains a file with broken 'last modified time'") - .unix_timestamp(); + let modification_time = zip_file.last_modified().to_time(); + + let time_in_seconds = match modification_time { + Ok(inner) => inner.unix_timestamp(), + _ => return Ok(()), + }; // Zip does not support nanoseconds, so we can assume zero here - let modification_time = FileTime::from_unix_time(modification_time_in_seconds, 0); + let modification_time = FileTime::from_unix_time(time_in_seconds, 0); set_file_mtime(path, modification_time)?;