fix: lower default version to 4.5 and use the version-needed-to-extract where feasible.

This commit is contained in:
Chris Hennick 2024-05-25 14:16:14 -07:00
parent 6d4e460556
commit 40f20d8a6b
No known key found for this signature in database
GPG key ID: DA47AABA4961C509
2 changed files with 4 additions and 6 deletions

View file

@ -388,7 +388,7 @@ impl TryFrom<DateTime> 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
}

View file

@ -1357,7 +1357,7 @@ impl<W: Write + Seek> ZipWriter<W> {
fn write_central_and_footer(&mut self) -> Result<u64, ZipError> {
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<W: Write + Seek> ZipWriter<W> {
|| 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,