From 40f20d8a6bc7de2959ea747ff8e633101f792c95 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Sat, 25 May 2024 14:16:14 -0700 Subject: [PATCH] fix: lower default version to 4.5 and use the version-needed-to-extract where feasible. --- src/types.rs | 6 ++---- src/write.rs | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/types.rs b/src/types.rs index 557600d0..ddab9928 100644 --- a/src/types.rs +++ b/src/types.rs @@ -388,7 +388,7 @@ impl TryFrom for OffsetDateTime { } } -pub const DEFAULT_VERSION: u8 = 46; +pub const DEFAULT_VERSION: u8 = 45; /// Structure representing a ZIP file. #[derive(Debug, Clone)] @@ -617,9 +617,7 @@ impl ZipFileData { extra_data_start, aes_extra_data_start, }; - local_block.version_made_by = local_block - .version_made_by - .max(local_block.version_needed() as u8); + local_block.version_made_by = local_block.version_needed() as u8; local_block } diff --git a/src/write.rs b/src/write.rs index b63d1de4..7f033794 100644 --- a/src/write.rs +++ b/src/write.rs @@ -1357,7 +1357,7 @@ impl ZipWriter { fn write_central_and_footer(&mut self) -> Result { let writer = self.inner.get_plain(); - let mut version_needed = 10; + let mut version_needed = 10; // Lowest value; even an empty ZIP file needs 1.0 let central_start = writer.stream_position()?; for file in self.files.values() { write_central_directory_header(writer, file)?; @@ -1369,7 +1369,7 @@ impl ZipWriter { || central_size.max(central_start) > spec::ZIP64_BYTES_THR { let zip64_footer = spec::Zip64CentralDirectoryEnd { - version_made_by: version_needed.max(DEFAULT_VERSION as u16), + version_made_by: version_needed, version_needed_to_extract: version_needed, disk_number: 0, disk_with_central_directory: 0,