-
Notifications
You must be signed in to change notification settings - Fork 9
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
Create intermediate directories when expanding #27
Conversation
@luispedro thanks for the PR. You are right that it be good to have the prefix directory created whenever a directory type entry is missing from the tarball itself. That said, such a scenario isn't a well formed tarball, for that reason, IMHO, it is better to create that directory only when lenient untarring is taking place. I'll comment directly on the commits with the few minor adjustments. |
src/Data/Conduit/Tar/Unix.hs
Outdated
@@ -111,6 +111,7 @@ restoreFileInternal lenient fi@FileInfo {..} = do | |||
return (either ((excs ++) . pure) (const excs) eExc) | |||
unless (null excs) $ yield (return (fi, excs)) | |||
FTNormal -> do | |||
liftIO $ Dir.createDirectoryIfMissing True $ Posix.takeDirectory fpStr |
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.
Make it create upon lenient
:
when lenient $ liftIO $ Dir.createDirectoryIfMissing True $ Posix.takeDirectory fpStr
Same approach probably should be added to FTSymbolicLink
as well
src/Data/Conduit/Tar/Windows.hs
Outdated
@@ -67,6 +68,7 @@ restoreFileInternal lenient fi@FileInfo {..} = do | |||
(`when` Dir.setModificationTime fpStr modTime)) | |||
return (fi, either ((excs ++) . pure) (const excs) eExc) | |||
FTNormal -> do | |||
Dir.createDirectoryIfMissing True $ FilePath.takeDirectory fpStr |
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.
Missing liftIO
as well as when lenient
conditional, just as in Unix.hs
module.
This matches the behaviour of command-line `tar` as well as other tar utilities. closes snoyberg#26
tests/Spec.hs
Outdated
around (withTempTarFiles baseTmp) $ | ||
it "create-intermediate" $ \(fpIn, hIn, outDir, fpOut) -> do | ||
hClose hIn | ||
extractTarball "tests/files/subdir.tar" (Just outDir) |
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.
extractTarballLenient
should be used here instead for two reasons:
- the attempt to restore ownership to
luispedro:luispedro
withuid
andgid
:1001:1001
for the test filesubdir.tar
causes the tests on travis to fail (since such user is missing from there) - test file is malformed (which is osk, since it is what we are trying to test here) and just as in the comment it should be restored leniently.
This is after feedback on the earlier version of the PR
ee9a70f
to
84d291f
Compare
Also, to answer your question question:
Yes there are. AppVeyor is setup and is currently failing for this PR due to my comment I do have a question about the test file |
On my Ubuntu machine: $ mkdir -p dir/subdir
$ echo "Hello World" > dir/subdir/file.txt
$ tar cf testing.tar dir/subdir/file.txt
$ ls -l testing.tar
-rw-rw-r-- 1 luispedro luispedro 10240 Jan 14 01:02 testing.tar Note, if I use |
Very interesting, didn't know about the default record size of 20 blocks for gnu tar:
So, doing:
would create a 2K file, instead of 10K. In any case, travis CI is still failing, cause the test file wasn't added to the cabal file's |
This matches the behaviour of command-line
tar
as well as other tar utilities.closes #26
I tested it on Linux, but also created a Windows version of the code (which I cannot test). Are there automated tests on Windows?