Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle Zip when modified times are missing #433

Merged
merged 1 commit into from
Jun 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/archive/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ 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 Ok(time_in_seconds) = modification_time else {
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.unix_timestamp(), 0);

set_file_mtime(path, modification_time)?;

Expand Down