-
Notifications
You must be signed in to change notification settings - Fork 187
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
Allow current directories in header paths #220
Conversation
Thanks for the report and PR! Could you elaborate though to the motivation for this? I'm not sure why it would be necessary to keep the |
For sure! The issue is paths passed into let mut header = Header::new_gnu();
let path = std::path::Path::new("./control");
header.set_path(&path).unwrap();
println!("Path: {}", path.display());
println!("Path in Header: {}", header.path().unwrap().display());
assert!(path == header.path().unwrap()); This will print
and then panic on the assertion. This makes it hard to iterate through a tar to find a file you put in it.
Maybe another option would be to provide a function which normalizes paths for the user so they can see how the path they passed into the crate might have changed? |
Ah ok, I see! Would counting files work alright for your use case? Indexing files by their position in the archive should be consisten across implementations |
Unfortunately, counting files will not work for me. There is no defined order for the files in the tar in my use case (more info below if you are curious). I have a simple work around to get past this issue, I was just filing this issue and this fix so that others do not run into this same issue. It took me a little while to figure out that tar-rs was silently swallowing the If you would prefer to not make this change, I'd like to switch this PR to document the behavior of the For more background: I'm trying to create and parse binary debian packages. The metadata for a binary debian package is stored in a file named "control" which in turn is inside a archive (control.tar). In most debian packages I have found in ubuntu's package repository the "control" file has a path of |
Thanks for the info! And yeah if you're ok documenting this for now, that seems good to me to add! |
Sounds good! For my own learning, why do you want to keep in this path normalization logic which strips paths of the current directory path? Is there some edge case related to the tar file format that we can avoid by doing this? |
Oh I'm not really particularly wed to the logic one way or another, I was mostly curious as to the motivations for this. Some degree of path normalization is done to avoid dealing with I don't think that anything would break with this but I'm not 100% confident myself, hence the question for motivation to see how deeply I needed to look! |
tar-rs will strip any current directory out of the paths users are passing into the API. This documents that behavior and adds a test to ensure the documented behavior.
My apologies for the delay. Updated this change to be documentation only. |
👍 |
tar-rs will strip any current directory out of the paths users are passing into the API. This documents that behavior and adds a test to ensure the documented behavior.
The current implementation removes any "current directories" from the
header path for a file. This change stops the removal to leave the path
as is.
This change adds a test to check for regression
Fixes #219