-
Notifications
You must be signed in to change notification settings - Fork 843
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
stack unpack: Ignore pax headers (fix #2361) #2363
stack unpack: Ignore pax headers (fix #2361) #2363
Conversation
This looks pretty good. I'm honestly not sure what the best way to handle the other case; maybe a warning would be the safest just so there are no surprises. Another idea would be to always try to set the permissions, just like before this patch, but treat failure asa warning for the weird/unknown cases (i.e., still an error if it fails for a regular file, directory, etc. but just a warning for character devices, OtherEntryType, etc.). |
Thanks for the prompt response!
That could work. But FWIW, those don't even get extracted by Orthogonally: GNU archives can use other flags. Since none correspond to files or are handled by |
Thanks for working on this, @Blaisorblade! :) I think I'd like to get a warning if the tarball contains a named pipe, and maybe the author would like to know too. So I'm in favor of extracting what we can reasonably use – just like what you have already implemented – and a warning about all the things that we can't. And could you please add a regression test that checks that the warning is present and that the unpacking works?! Cheers! |
First down, the warnings (output yet untested). Using foldEntries is surprisingly ugly; I've tried converting to and from a list but it might not be better :-(. Next up, tests! |
775df73
to
88776f7
Compare
So, since I like unit tests, I ended up with some refactorings and harmless changes to make this code unit-testable. I also haven't seen unit tests with data, so I had to get creative there. |
I don't get the AppVeyor failure, and it doesn't seem about my testcase. If AppVeyor is flaky like Travis, could you restart the AppVeyor build? There is enough path manipulation that it matters that it passes. There's no clear indication it's about my testcase, and the actual code in main should still do essentially the same thing (except for 98e2ec0). Also master already broke in https://ci.appveyor.com/project/snoyberg/stack/build/1.0.1867, and |
No, I don't have the necessary permissions. Pinging @snoyberg. |
Rebuilt. In the future, doing |
It failed again — I started investigating the failure. |
Oh man, these Appveyor log files are absolutely unreadable.
WTF! |
@sjakobi Please worry not, I've figured it out, it was my fault and I've got green builds now: |
Prepare to split this function to have unit tests for it. This change should be harmless but is not a refactoring, separating this for testing.
* Stop trying to reset permissions on pax header entries. * Add changelog entry. * Output warnings for unexpected entries. * Add testcases. The interface of untar is designed for unit testing.
88776f7
to
2fb8bdc
Compare
I force-pushed based on this success (https://ci.appveyor.com/project/Blaisorblade/stack/build/1.0.11), got a hung build after rebasing on master but that's hopefully just flaky or not having to do with the new code (I'm trying to rebuild that). Meanwhile, I think this is ready for review. |
-- Takes a path to a .tar.gz file, the name of the directory it should contain, | ||
-- and a destination folder to extract the tarball into. Returns unexpected | ||
-- entries, as pairs of paths and descriptions. | ||
untar :: FilePath -> FilePath -> FilePath -> IO [(FilePath, T.Text)] |
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 would prefer to see Path
being used here as much as possible / reasonable. IMO the distinction between the different Path
types makes code (especially type signatures) more readable and slightly more robust.
You can find utils for working with Path
in src/Path
(especially the amazing Path.Extra.toFilePathNoTrailingSep
;)) and in the path-io
package.
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've seen path-io, but this is not trivial since this code has to talk to non-path-ified code.
But you have a point about signatures.
Also, the existing code uses FilePath quite a lot, see all the FP.</>
. I guess you'd be fine with changes to the existing code, both as strictly needed to change untar
's signature and as it makes sense? I'll see what I can do later.
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.
but this is not trivial since this code has to talk to non-path-ified code.
Yes, I guess for the return value that is only going to be printed it doesn't matter as much. But for the input types it would be great, so we can encourage further usage of Path
in any callers of untar
.
Also, the existing code uses FilePath quite a lot, see all the FP.</>.
Yes, there's a lot of room for improvement in this codebase! ;)
Nice! Great code, @Blaisorblade, the tests are totally awesome! This will be ready to merge once my comment above has been addressed! |
Thanks! Happy to hear that, also because I got them very wrong the first time (so I should have asked for a close look there)—I was adding the tests only after all the actions in IO succeeded: |
Now I can also use Path's `ensureDir` again (I had to inline it to `D.createDirectoryIfMissing True`). Also, inline calls to toFilePath in untar, because: 1. toFilePath costs nothing so the inlining is safe. 2. Having to name both the Path and FilePath variants of the same variable means looking for trouble.
@sjakobi Converting a bit more to |
Awesome, LGTM! Merging |
Stop trying to reset permissions on pax header entries. This fixed the bug as verified by
stack exec -- stack unpack ghc-core
andstack exec -- stack install ghc-core
. Haven't tested on other packages or on the testsuite (I'm relying on CI).XXX This is incomplete, see XXX case in the patch. I'm not sure how defensive to be for the case that some tar entry is not one of the known entry types. Also, I've not checked other tar formats than
pax
, so maybe there's more to expect.Quite possibly, the code should just have a catchall case for all cases leading to False or at least for all
Tar.OtherEntryType
entries, and then I can dispense with all these complications.Fix #2361.