diff --git a/src/base/write/entry_stream.rs b/src/base/write/entry_stream.rs index 049a31d..cc41f0e 100644 --- a/src/base/write/entry_stream.rs +++ b/src/base/write/entry_stream.rs @@ -178,7 +178,8 @@ impl<'b, W: AsyncWrite + Unpin> EntryStreamWriter<'b, W> { let (cdr_compressed_size, cdr_uncompressed_size, lh_offset) = if self.force_no_zip64 { if uncompressed_size > NON_ZIP64_MAX_SIZE as u64 || compressed_size > NON_ZIP64_MAX_SIZE as u64 - || self.lfh_offset > NON_ZIP64_MAX_SIZE as u64 { + || self.lfh_offset > NON_ZIP64_MAX_SIZE as u64 + { return Err(ZipError::Zip64Needed(Zip64ErrorCase::LargeFile)); } (uncompressed_size as u32, compressed_size as u32, self.lfh_offset as u32) diff --git a/src/base/write/entry_whole.rs b/src/base/write/entry_whole.rs index 10e9d0e..34594b6 100644 --- a/src/base/write/entry_whole.rs +++ b/src/base/write/entry_whole.rs @@ -81,12 +81,11 @@ impl<'b, 'c, W: AsyncWrite + Unpin> EntryWholeWriter<'b, 'c, W> { } if let Some(zip64_extra_field) = zip64_extra_field_builder { - zip64_extra_field_builder = - Some(zip64_extra_field.relative_header_offset(self.writer.writer.offset() as u64)); + zip64_extra_field_builder = Some(zip64_extra_field.relative_header_offset(self.writer.writer.offset())); } else { zip64_extra_field_builder = Some( Zip64ExtendedInformationExtraFieldBuilder::new() - .relative_header_offset(self.writer.writer.offset() as u64), + .relative_header_offset(self.writer.writer.offset()), ); } NON_ZIP64_MAX_SIZE diff --git a/src/base/write/mod.rs b/src/base/write/mod.rs index 5765f9c..a571d61 100644 --- a/src/base/write/mod.rs +++ b/src/base/write/mod.rs @@ -168,7 +168,7 @@ impl ZipFileWriter { self.writer.write_all(comment_basic).await?; } - let central_directory_size = (self.writer.offset() - cd_offset) as u64; + let central_directory_size = self.writer.offset() - cd_offset; let central_directory_size_u32 = if central_directory_size > NON_ZIP64_MAX_SIZE as u64 { NON_ZIP64_MAX_SIZE } else { @@ -180,7 +180,6 @@ impl ZipFileWriter { } else { num_entries_in_directory as u16 }; - let cd_offset = cd_offset as u64; let cd_offset_u32 = if cd_offset > NON_ZIP64_MAX_SIZE as u64 { if self.force_no_zip64 { return Err(crate::error::ZipError::Zip64Needed(crate::error::Zip64ErrorCase::LargeFile)); @@ -212,7 +211,7 @@ impl ZipFileWriter { let eocdl = Zip64EndOfCentralDirectoryLocator { number_of_disk_with_start_of_zip64_end_of_central_directory: 0, - relative_offset: eocdr_offset as u64, + relative_offset: eocdr_offset, total_number_of_disks: 1, }; self.writer.write_all(&crate::spec::consts::ZIP64_EOCDL_SIGNATURE.to_le_bytes()).await?; diff --git a/src/spec/extra_field.rs b/src/spec/extra_field.rs index aefae67..7506e95 100644 --- a/src/spec/extra_field.rs +++ b/src/spec/extra_field.rs @@ -257,14 +257,9 @@ pub(crate) fn extra_field_from_bytes( compressed_size: u32, ) -> ZipResult { match header_id { - HeaderId::ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD => { - Ok(ExtraField::Zip64ExtendedInformation(zip64_extended_information_field_from_bytes( - header_id, - data, - uncompressed_size, - compressed_size, - )?)) - } + HeaderId::ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD => Ok(ExtraField::Zip64ExtendedInformation( + zip64_extended_information_field_from_bytes(header_id, data, uncompressed_size, compressed_size)?, + )), HeaderId::INFO_ZIP_UNICODE_COMMENT_EXTRA_FIELD => Ok(ExtraField::InfoZipUnicodeComment( info_zip_unicode_comment_extra_field_from_bytes(header_id, data_size, data)?, )),