Skip to content

Commit

Permalink
Fix formating and clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Shmarov authored and Majored committed Dec 22, 2023
1 parent 32dea78 commit 36333f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/base/write/entry_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions src/base/write/entry_whole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/base/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<W: AsyncWrite + Unpin> ZipFileWriter<W> {
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 {
Expand All @@ -180,7 +180,6 @@ impl<W: AsyncWrite + Unpin> ZipFileWriter<W> {
} 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));
Expand Down Expand Up @@ -212,7 +211,7 @@ impl<W: AsyncWrite + Unpin> ZipFileWriter<W> {

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?;
Expand Down
11 changes: 3 additions & 8 deletions src/spec/extra_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,9 @@ pub(crate) fn extra_field_from_bytes(
compressed_size: u32,
) -> ZipResult<ExtraField> {
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)?,
)),
Expand Down

0 comments on commit 36333f2

Please sign in to comment.