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

ungzip truncates concatinated gz streams #267

Closed
lpsmith opened this issue Jun 11, 2016 · 1 comment
Closed

ungzip truncates concatinated gz streams #267

lpsmith opened this issue Jun 11, 2016 · 1 comment

Comments

@lpsmith
Copy link

lpsmith commented Jun 11, 2016

Likely closely related to snapframework/io-streams#56

I recently learned that it's perfectly acceptable to concatinate gz streams, and gunzip and zcat will decompress each stream and concatinate the result. So starting with this minimal reimplementation of zcat:

import Data.Conduit (($$), ($=))
import Control.Monad.Trans.Resource(runResourceT)
import qualified Data.Conduit.Binary as CB
import Data.Conduit.Zlib
import System.IO
import System.Environment

main = do
    (filename:_) <- getArgs
    runResourceT $ CB.sourceFile filename $= ungzip $$ CB.sinkHandle stdout

Then, in the shell, here's a minimal demonstration of the problem:

$ echo Hello | gzip > foo.gz
$ echo World | gzip >> foo.gz
$ dist/build/zcat/zcat foo.gz
Hello
$ zcat foo.gz
Hello
World
$ gunzip foo.gz
$ cat foo
Hello
World
@lpsmith
Copy link
Author

lpsmith commented Jun 11, 2016

Ahh, my apologies for overlooking multiple. This probably isn't great UX, given the lack of correspondence between ungzip and gunzip.

@lpsmith lpsmith closed this as completed Jun 11, 2016
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

1 participant