On Wed, 20 Jan 2016 at 16:10 'Klaus Aehlig' via ganeti-devel < [email protected]> wrote:
> For decompression with proper error handling, Ganeti used to use > the function decompressWithErrors. This function, however, does not > exist any more in zlib 6.0 and higher. Therefore provide an alternative > implementation that works for those versions. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/Codec.hs | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/src/Ganeti/Codec.hs b/src/Ganeti/Codec.hs > index 9a41499..a703ba8 100644 > --- a/src/Ganeti/Codec.hs > +++ b/src/Ganeti/Codec.hs > @@ -1,10 +1,12 @@ > +{-# LANGUAGE CPP #-} > + > {-| Provides interface to the 'zlib' library. > > -} > > {- > > -Copyright (C) 2014 Google Inc. > +Copyright (C) 2014, 2016 Google Inc. > All rights reserved. > > Redistribution and use in source and binary forms, with or without > @@ -43,9 +45,9 @@ import Ganeti.Prelude > import Codec.Compression.Zlib (compress) > import qualified Codec.Compression.Zlib.Internal as I > import Control.Monad (liftM) > -import Control.Monad.Error.Class (MonadError(..)) > import qualified Data.ByteString.Lazy as BL > import qualified Data.ByteString.Lazy.Internal as BL > +import Control.Monad.Error.Class (MonadError(..)) > > import Ganeti.BasicTypes > > @@ -57,6 +59,13 @@ compressZlib = compress > -- 'throwError'. > decompressZlib :: (MonadError e m, FromString e) > => BL.ByteString -> m BL.ByteString > +#if MIN_VERSION_zlib(0, 6, 0) > +decompressZlib = I.foldDecompressStreamWithInput > + (liftM . BL.chunk) > + return > + (throwError . mkFromString . (++)"Zlib: " . show) > + $ I.decompressST I.zlibFormat I.defaultDecompressParams > +#else > decompressZlib = I.foldDecompressStream > (liftM . BL.chunk) > (return mempty) > @@ -64,3 +73,4 @@ decompressZlib = I.foldDecompressStream > . I.decompressWithErrors > I.zlibFormat > I.defaultDecompressParams > +#endif > -- > 2.7.0.rc3.207.g0ac5344 > > LGTM, thanks -- Helga Velroyen Software Engineer [email protected] Google Germany GmbH Erika-Mann-Strasse 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks.
