Skip to content

refactor: simplify extra field parsing#764

Merged
Pr0methean merged 8 commits intomasterfrom
simplify-extra-fields-parsing
Apr 6, 2026
Merged

refactor: simplify extra field parsing#764
Pr0methean merged 8 commits intomasterfrom
simplify-extra-fields-parsing

Conversation

@Its-Just-Nans
Copy link
Copy Markdown
Member

  • The PR title must conform to Conventional Commits

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactoring successfully simplifies extra field parsing by moving parsing logic into the respective struct implementations. The changes improve code organization and maintainability while preserving existing behavior. No blocking issues found.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread src/extra_fields/aex_encryption.rs Fixed
Comment thread src/extra_fields/aex_encryption.rs Fixed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the parsing of ZIP extra fields by moving the logic for AexEncryption and Zip64ExtendedInformation into dedicated parse methods. It also implements TryFrom for AesVendorVersion and AesMode to simplify conversion logic. Feedback includes fixing compilation errors caused by missing size_of imports in zip64_extended_information.rs and optimizing byte skipping to avoid unnecessary heap allocations.

Comment thread src/extra_fields/zip64_extended_information.rs Outdated
Comment thread src/extra_fields/zip64_extended_information.rs Outdated
Comment thread src/extra_fields/zip64_extended_information.rs Outdated
let Some(leftover_len) = (len as usize).checked_sub(consumed_len) else {
return Err(invalid!("ZIP64 extra-data field is the wrong length"));
};
if let Err(e) = reader.read_exact(&mut vec![0u8; leftover_len]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Allocating a Vec on the heap just to skip bytes is inefficient, especially when processing many files in a large archive. Consider using a small stack-allocated buffer or std::io::copy with std::io::sink() to skip the remaining bytes without unnecessary allocations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Its-Just-Nans Its-Just-Nans requested a review from Pr0methean April 5, 2026 15:34
Pr0methean
Pr0methean previously approved these changes Apr 5, 2026
Copy link
Copy Markdown
Member

@Pr0methean Pr0methean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Could use one minor change, which I'll commit.

Comment thread src/extra_fields/aex_encryption.rs Outdated
@Pr0methean Pr0methean enabled auto-merge April 5, 2026 22:04
@Pr0methean Pr0methean added this pull request to the merge queue Apr 6, 2026
Merged via the queue into master with commit f6c64ff Apr 6, 2026
133 checks passed
@Pr0methean Pr0methean deleted the simplify-extra-fields-parsing branch April 6, 2026 02:52
@Pr0methean Pr0methean mentioned this pull request Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants