snoyberg / tar-conduit

Conduit based tar extraction mechanism
MIT License
8 stars 9 forks source link

Creating files should create the with the containing directory #26

Closed luispedro closed 5 years ago

luispedro commented 5 years ago

When expanding a tar file containing which contains a file inside a subdirectory, the subdirectory is not created (unlike the case with other tar tools).

I attach a tar file which demonstrates this and here's a little script to trigger the error (you need to ungzip the test.tar.gz file first to get test.tar):

#!/usr/bin/env stack
-- stack --resolver lts-13.1 runghc --package tar-conduit --package conduit
module Main where

import qualified Data.Conduit.Tar as CTar
import qualified Conduit as C
import           Conduit ((.|))
import qualified Data.ByteString as B
import           System.Environment (getArgs)

main :: IO ()
main = do
    fs <- getArgs
    case fs of
        [f] -> C.runConduitRes $
                    C.sourceFileBS f
                       .| CTar.untarWithFinalizers (CTar.restoreFileInto ".")
        _ -> error "Use a single argument to Expand.hs"

test.tar.gz