-
Notifications
You must be signed in to change notification settings - Fork 191
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
Very basic Pax header writer #382
Conversation
f148ee5
to
f804ba9
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.
Thanks for your contribution! Procedural notes:
- If you wouldn't mind please squash your commits, I don't think any of the 4 stand alone
- Can you rework your commit message to be "Linux kernel style" which I try to use, see e.g. https://cbea.ms/git-commit/
I'd propose something like this:
Add support for writing PAX headers
While this crate has always supported reading these attributes,
writing them was up to the user. Add an API to do this.
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.
Marking requested changes per above
47f0045
to
92af5e5
Compare
All comments fixed. |
This crate currently supports reading the PAX headers. This adds a way to write some PAX headers in a Builder. Also implemented tests to showcase usage
92af5e5
to
3c86863
Compare
Can you add these changes? First we don't need to require passing owned data, and according to the spec the value can be arbitrary binary data.
|
Since we can keep the ownership of the data when calling append_pax_extensions, we can use &str and &[u8] according to the lib documentation
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.
Just two minor nits but they're not important so merging, we can do followup fixes if we want.
Thanks for your contribution!
@@ -1,7 +1,8 @@ | |||
extern crate tar; | |||
extern crate tempfile; | |||
|
|||
use std::fs::{create_dir, File}; | |||
use std::fs::create_dir; |
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.
I don't care too much but this change seem spurious i.e. unnecessary
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.
Didn't realize at the time, not intended. Won't fix since it's not that important
@@ -145,3 +146,50 @@ impl<'entry> PaxExtension<'entry> { | |||
self.value | |||
} | |||
} | |||
|
|||
/// Extension trait for `Builder` to append PAX extended headers. |
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.
This isn't an extension trait anymore
When I was playing with this I noticed that my suggestion of using I dunno how much of a real world problem this is. It does sure look to me like in e.g. the python tar parser it's actually expected to be UTF-8. |
For general interest I used this to fix a bug in my software - thank you for submitting this patch! cc ostreedev/ostree-rs-ext#679 |
This could be fixed, but I'm not sure it would add any "bonus" as str is used for an utf8 string for the key anyway. |
Made a PR if want to switch the usage of key but it might be a breaking change if already used by someone |
Basic implem of PaxBuilder that can add the header with the data provided, implem on tar::builder
Today the lib is able to read the pax headers, even if they have arbitrary values but can't write some headers back. This update lets you do that very simply.
Usage: