cabal-install 1.22.6.0 → 1.22.7.0
raw patch · 4 files changed
+55/−8 lines, 4 filesdep ~HTTPdep ~QuickCheckdep ~zlib
Dependency ranges changed: HTTP, QuickCheck, zlib
Files
- Distribution/Client/GZipUtils.hs +46/−4
- bootstrap.sh +1/−1
- cabal-install.cabal +3/−3
- changelog +5/−0
Distribution/Client/GZipUtils.hs view
@@ -1,3 +1,6 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE CPP #-}+ ----------------------------------------------------------------------------- -- | -- Module : Distribution.Client.GZipUtils@@ -15,11 +18,16 @@ maybeDecompress, ) where -import qualified Data.ByteString.Lazy.Internal as BS (ByteString(..))-import Data.ByteString.Lazy (ByteString)-import Codec.Compression.GZip import Codec.Compression.Zlib.Internal+import Data.ByteString.Lazy.Internal as BS (ByteString(Empty, Chunk)) +#if MIN_VERSION_zlib(0,6,0)+import Control.Exception (throw)+import Control.Monad (liftM)+import Control.Monad.ST.Lazy (ST, runST)+import qualified Data.ByteString as Strict+#endif+ -- | Attempts to decompress the `bytes' under the assumption that -- "data format" error at the very beginning of the stream means -- that it is already decompressed. Caller should make sanity checks@@ -30,15 +38,49 @@ -- <https://github.com/haskell/cabal/issues/678> -- maybeDecompress :: ByteString -> ByteString+#if MIN_VERSION_zlib(0,6,0)+maybeDecompress bytes = runST (go bytes decompressor)+ where+ decompressor :: DecompressStream (ST s)+ decompressor = decompressST gzipOrZlibFormat defaultDecompressParams++ -- DataError at the beginning of the stream probably means that stream is+ -- not compressed, so we return it as-is.+ -- TODO: alternatively, we might consider looking for the two magic bytes+ -- at the beginning of the gzip header. (not an option for zlib, though.)+ go :: Monad m => ByteString -> DecompressStream m -> m ByteString+ go cs (DecompressOutputAvailable bs k) = liftM (Chunk bs) $ go' cs =<< k+ go _ (DecompressStreamEnd _bs ) = return Empty+ go _ (DecompressStreamError _err ) = return bytes+ go cs (DecompressInputRequired k) = go cs' =<< k c+ where+ (c, cs') = uncons cs++ -- Once we have received any output though we regard errors as actual errors+ -- and we throw them (as pure exceptions).+ -- TODO: We could (and should) avoid these pure exceptions.+ go' :: Monad m => ByteString -> DecompressStream m -> m ByteString+ go' cs (DecompressOutputAvailable bs k) = liftM (Chunk bs) $ go' cs =<< k+ go' _ (DecompressStreamEnd _bs ) = return Empty+ go' _ (DecompressStreamError err ) = throw err+ go' cs (DecompressInputRequired k) = go' cs' =<< k c+ where+ (c, cs') = uncons cs++ uncons :: ByteString -> (Strict.ByteString, ByteString)+ uncons Empty = (Strict.empty, Empty)+ uncons (Chunk c cs) = (c, cs)+#else maybeDecompress bytes = foldStream $ decompressWithErrors gzipOrZlibFormat defaultDecompressParams bytes where -- DataError at the beginning of the stream probably means that stream is not compressed. -- Returning it as-is. -- TODO: alternatively, we might consider looking for the two magic bytes -- at the beginning of the gzip header.- foldStream (StreamError DataError _) = bytes+ foldStream (StreamError _ _) = bytes foldStream somethingElse = doFold somethingElse doFold StreamEnd = BS.Empty doFold (StreamChunk bs stream) = BS.Chunk bs (doFold stream) doFold (StreamError _ msg) = error $ "Codec.Compression.Zlib: " ++ msg+#endif
bootstrap.sh view
@@ -190,7 +190,7 @@ # >= 2.0 && < 2.7 NETWORK_URI_VER="2.6.0.1"; NETWORK_URI_VER_REGEXP="2\.6\." # >= 2.6 && < 2.7-CABAL_VER="1.22.4.0"; CABAL_VER_REGEXP="1\.22"+CABAL_VER="1.22.6.0"; CABAL_VER_REGEXP="1\.22" # >= 1.22 && < 1.23 TRANS_VER="0.4.2.0"; TRANS_VER_REGEXP="0\.[4]\." # >= 0.2.* && < 0.5
cabal-install.cabal view
@@ -1,5 +1,5 @@ Name: cabal-install-Version: 1.22.6.0+Version: 1.22.7.0 Synopsis: The command-line interface for Cabal and Hackage. Description: The \'cabal\' command-line program simplifies the process of managing@@ -138,7 +138,7 @@ random >= 1 && < 1.2, stm >= 2.0 && < 3, time >= 1.1 && < 1.6,- zlib >= 0.5.3 && < 0.6+ zlib >= 0.5.3 && < 0.7 if flag(old-directory) build-depends: directory >= 1 && < 1.2, old-time >= 1 && < 1.2,@@ -236,7 +236,7 @@ build-depends: Cabal, HUnit,- QuickCheck >= 2.1.0.1 && < 2.8,+ QuickCheck >= 2.1.0.1 && < 2.9, base, bytestring, directory,
changelog view
@@ -1,4 +1,9 @@ -*-change-log-*-+1.22.7.0+ * Remove GZipUtils tests+ * maybeDecompress: bail on all errors at the beginning of the stream with zlib < 0.6+ * Correct maybeDecompress+ 1.22.6.0 Ryan Thomas <ryan@ryant.org> June 2015 * A fix for @ezyang's fix for #2502. (Mikhail Glushenkov)