Skip to content
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

[QUESTION] path transformation when creating tar file #271

Closed
fholzer opened this issue Jan 27, 2021 · 5 comments
Closed

[QUESTION] path transformation when creating tar file #271

fholzer opened this issue Jan 27, 2021 · 5 comments

Comments

@fholzer
Copy link

fholzer commented Jan 27, 2021

What / Why

While I found an of old issue (#10) and a closed PR (#17) about transforming the file path when writing a tar file, and there are references to "this now being possible in v3" I couldn't find any documentation of example of how this can actually be done.
As there is no transform cb when creating a tar file that could be used to do that, and the low level API seems quite closed in terms of what is exposed to outside classes due to the extensive use of Symbols, I'm wondering if you could clarify if path transformations are sill possible with v6, and maybe some pointers in the right direction or how an implementation of this could look like.

@isaacs
Copy link
Owner

isaacs commented Jul 28, 2021

When unpacking you can do this with an onentry method that changes the paths or a transform method that returns a new stream for the contents. But when packing there's no straightforward way to change the paths as of tar v4.

I am open to adding both to the Pack class to match this feature of gnutar.

@isaacs
Copy link
Owner

isaacs commented Aug 2, 2021

Adding an onentry (which could modify path and other header information) is straightforward. However, a content transform is a bit more complicated, since the file reading and buffer-padding logic is all optimized and unrolled, rather than going through a Stream class.

@fholzer
Copy link
Author

fholzer commented Dec 10, 2021

Closing this, as my issue was just about path transformation, not content transformation.

Thanks for this!

@fholzer fholzer closed this as completed Dec 10, 2021
@gramakri
Copy link

gramakri commented Jul 4, 2024

Was path transformation when creating tar files implemented? The onWriteEntry is called too late for path transformation

@isaacs
Copy link
Owner

isaacs commented Jul 26, 2024

Indeed, it's being called after the Header is already encoded, so that's not much help, is it? Fixing now.

@isaacs isaacs reopened this Jul 26, 2024
@isaacs isaacs closed this as completed in bf13718 Jul 26, 2024
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

No branches or pull requests

3 participants