-
-
Notifications
You must be signed in to change notification settings - Fork 408
Replace zip crate with rawzip in gix-archive #2294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
c04eb69 to
c01545f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates gix-archive from the zip crate to rawzip for ZIP archive creation, removing transitive dependencies (arbitrary, derive_arbitrary) from the dependency tree.
Key changes:
- Replaces
zipcrate withrawzipand usesflate2directly for deflate compression - Updates archive writing to use rawzip's API with explicit compression handling via
DeflateEncoder - Adjusts tests to use rawzip's reading API and updates size expectations (~7% larger archives)
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| gix-archive/Cargo.toml | Replaces zip dependency with rawzip and adds flate2 to zip feature |
| Cargo.lock | Removes zip, arbitrary, and derive_arbitrary dependencies; adds rawzip |
| gix-archive/src/write.rs | Implements ZIP archive writing using rawzip API with explicit flate2 compression, proper UTF-8 error handling, and ensures directory paths end with / |
| gix-archive/tests/archive.rs | Updates tests to use rawzip's reading API and adjusts size threshold from 1280 to 1400 bytes |
gix-archive/src/write.rs
Outdated
| ar.start_file(path.to_string(), file_opts) | ||
| .map_err(std::io::Error::other)?; | ||
| std::io::copy(&mut entry, ar)?; | ||
| use bstr::ByteSlice; |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use bstr::ByteSlice; statement is repeated in all three match arms (lines 174, 203, and 224). For better maintainability, consider moving this import to the top of the function, just after line 168, so it's available for all match arms without repetition.
c01545f to
1132f57
Compare
1132f57 to
8c9b4d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
gix-archive/src/write.rs
Outdated
| let path = path.to_str().map_err(|_| { | ||
| Error::Io(std::io::Error::new( | ||
| std::io::ErrorKind::InvalidData, | ||
| format!("Invalid UTF-8 in entry path: {path}"), |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message format string uses the Display implementation for BString, which may not be ideal for debugging UTF-8 issues. Consider using either the Debug formatting with {path:?} to show the raw bytes, or use String::from_utf8_lossy(path.as_ref()) in the error message to show what the path would look like with replacement characters, which would make it easier to identify the problematic characters.
| format!("Invalid UTF-8 in entry path: {path}"), | |
| format!("Invalid UTF-8 in entry path: {path:?}"), |
gix-archive/src/write.rs
Outdated
| Error::Io(std::io::Error::new( | ||
| std::io::ErrorKind::InvalidData, | ||
| "Invalid UTF-8 in symlink target", |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message would be more helpful if it included the symlink path and showed what the invalid target looks like. Consider including the symlink path in the error and using String::from_utf8_lossy to show the target with replacement characters for debugging.
| Error::Io(std::io::Error::new( | |
| std::io::ErrorKind::InvalidData, | |
| "Invalid UTF-8 in symlink target", | |
| let lossy_target = String::from_utf8_lossy(buf.as_slice()); | |
| Error::Io(std::io::Error::new( | |
| std::io::ErrorKind::InvalidData, | |
| format!( | |
| "Invalid UTF-8 in symlink target for entry '{symlink_path}': {lossy_target}" | |
| ), |
|
Related to #2293 . |
Migrates
gix-archivefrom thezipcrate torawzipfor ZIP archive creation.Changes
Dependencies: Replaced
zip = "6.0.0"withrawzip = "0.4.2"and addedflate2to zip feature (required for deflate compression)Archive writing (
write.rs):rawzip::ZipArchiveWriterwith explicitflate2::DeflateEncoderfor compressionUtcDateTime::from_unix(seconds)instead of manual date/time component conversion/(rawzip requirement)Tests (
archive.rs):ZipArchive::from_slice(),mode().is_symlink(),mode().value(),get_entry().data()API differences
All existing tests pass. The
zipcrate and its transitive dependencies (arbitrary,derive_arbitrary) are removed from the dependency tree.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.