zip 1.7.2 → 2.0.0
raw patch · 6 files changed
+43/−53 lines, 6 filesdep ~QuickCheckdep ~basedep ~bytestring
Dependency ranges changed: QuickCheck, base, bytestring, dlist, hspec, mtl, text, transformers
Files
- CHANGELOG.md +6/−0
- Codec/Archive/Zip.hs +2/−2
- Codec/Archive/Zip/Internal.hs +5/−5
- Codec/Archive/Zip/Type.hs +13/−32
- tests/Main.hs +6/−3
- zip.cabal +11/−11
CHANGELOG.md view
@@ -1,3 +1,9 @@+## Zip 2.0.0++* Unified `BZip2Unsupported` and `ZstdUnsupported` into a single data+ constructor `UnsupportedCompressionMethod` with a `CompressionMethod`+ field.+ ## Zip 1.7.2 * Now the ZIP64 extra field is only written when it is necessary. Previously
Codec/Archive/Zip.hs view
@@ -233,7 +233,7 @@ -- specified file if it already exists. See 'withArchive' if you want to -- work with an existing archive. createArchive ::- MonadIO m =>+ (MonadIO m) => -- | Location of the archive file to create FilePath -> -- | Actions that create the archive's content@@ -277,7 +277,7 @@ -- design decision to make it impossible to create non-portable archives -- with this library. withArchive ::- MonadIO m =>+ (MonadIO m) => -- | Location of the archive to work with FilePath -> -- | Actions on that archive
Codec/Archive/Zip/Internal.hs view
@@ -598,14 +598,14 @@ withCompression $ BZ.bzip2 .| dataSink #else- BZip2 -> throwM BZip2Unsupported+ BZip2 -> throwM (UnsupportedCompressionMethod BZip2) #endif #ifdef ENABLE_ZSTD Zstd -> withCompression $ Zstandard.compress 1 .| dataSink #else- Zstd -> throwM ZstdUnsupported+ Zstd -> throwM (UnsupportedCompressionMethod Zstd) #endif return DataDescriptor@@ -1033,7 +1033,7 @@ -- Helpers -- | Rename an entry (key) in a 'Map'.-renameKey :: Ord k => k -> k -> Map k a -> Map k a+renameKey :: (Ord k) => k -> k -> Map k a -> Map k a renameKey ok nk m = case M.lookup ok m of Nothing -> m Just e -> M.insert nk e (M.delete ok m)@@ -1152,13 +1152,13 @@ #ifdef ENABLE_BZIP2 decompressingPipe BZip2 = BZ.bunzip2 #else-decompressingPipe BZip2 = throwM BZip2Unsupported+decompressingPipe BZip2 = throwM (UnsupportedCompressionMethod BZip2) #endif #ifdef ENABLE_ZSTD decompressingPipe Zstd = Zstandard.decompress #else-decompressingPipe Zstd = throwM ZstdUnsupported+decompressingPipe Zstd = throwM (UnsupportedCompressionMethod Zstd) #endif -- | A sink that calculates the CRC32 check sum for an incoming stream.
Codec/Archive/Zip/Type.hs view
@@ -93,7 +93,7 @@ -- 65535 bytes -- -- This function can throw an 'EntrySelectorException'.-mkEntrySelector :: MonadThrow m => FilePath -> m EntrySelector+mkEntrySelector :: (MonadThrow m) => FilePath -> m EntrySelector mkEntrySelector path = let f x = case filter (not . FP.isPathSeparator) x of@@ -203,48 +203,29 @@ ---------------------------------------------------------------------------- -- Exceptions -{- ORMOLU_DISABLE -}- -- | The bad things that can happen when you use the library. data ZipException = -- | Thrown when you try to get contents of non-existing entry EntryDoesNotExist FilePath EntrySelector-#ifndef ENABLE_BZIP2- -- | Thrown when attempting to decompress a 'BZip2' entry and the- -- library is compiled without support for it.- --- -- @since 1.3.0- | BZip2Unsupported-#endif-#ifndef ENABLE_ZSTD- -- | Thrown when attempting to decompress a 'Zstd' entry and the- -- library is compiled without support for it.+ | -- | Thrown when attempting to decompress an entry compressed with an+ -- unsupported compression method or the library is compiled without+ -- support for it. --- -- @since 1.6.0- | ZstdUnsupported-#endif- -- | Thrown when archive structure cannot be parsed.- | ParsingFailed FilePath String+ -- @since 2.0.0+ UnsupportedCompressionMethod CompressionMethod+ | -- | Thrown when archive structure cannot be parsed.+ ParsingFailed FilePath String deriving (Eq, Ord, Typeable) -{- ORMOLU_ENABLE -}- instance Show ZipException where show (EntryDoesNotExist file s) = "No such entry found: " ++ show s ++ " in " ++ show file show (ParsingFailed file msg) = "Parsing of archive structure failed: \n" ++ msg ++ "\nin " ++ show file--#ifndef ENABLE_BZIP2- show BZip2Unsupported =- "Encountered a zipfile entry with BZip2 compression, but " ++- "the zip library has been built with bzip2 disabled."-#endif--#ifndef ENABLE_ZSTD- show ZstdUnsupported =- "Encountered a zipfile entry with Zstd compression, but " ++- "the zip library has been built with zstd disabled."-#endif+ show (UnsupportedCompressionMethod method) =+ "Encountered a zipfile entry with "+ ++ show method+ ++ " compression, but "+ ++ "zip library does not support it or has been built without support for it." instance Exception ZipException
tests/Main.hs view
@@ -118,7 +118,8 @@ resize 10 $ intercalate "/" <$> listOf1- ( (++) <$> vectorOf 3 charGen+ ( (++)+ <$> vectorOf 3 charGen <*> listOf1 charGen ) case mkEntrySelector p of@@ -196,7 +197,8 @@ instance Show EntryDescription where show ed =- "{ edCompression = " ++ show (edCompression ed)+ "{ edCompression = "+ ++ show (edCompression ed) ++ "\n, edModTime = " ++ show (edModTime ed) ++ "\n, edUncompressedSize = "@@ -411,7 +413,8 @@ info <- createArchive path $ do sinkEntry m (C.yield b) s commit- (,) <$> sourceEntry s (CL.foldMap id)+ (,)+ <$> sourceEntry s (CL.foldMap id) <*> (edCompression . (! s) <$> getEntries) info `shouldBe` (b, m)
zip.cabal view
@@ -1,11 +1,11 @@-cabal-version: 1.18+cabal-version: 2.4 name: zip-version: 1.7.2-license: BSD3+version: 2.0.0+license: BSD-3-Clause license-file: LICENSE.md maintainer: Mark Karpov <markkarpov92@gmail.com> author: Mark Karpov <markkarpov92@gmail.com>-tested-with: ghc ==8.8.4 ghc ==8.10.5 ghc ==9.0.1+tested-with: ghc ==9.0.1 ghc ==9.2.5 ghc ==9.4.4 homepage: https://github.com/mrkkrp/zip bug-reports: https://github.com/mrkkrp/zip/issues synopsis: Operations on zip archives@@ -51,7 +51,7 @@ default-language: Haskell2010 build-depends:- base >=4.13 && <5.0,+ base >=4.15 && <5.0, bytestring >=0.9 && <0.12, case-insensitive >=1.2.0.2 && <1.3, cereal >=0.3 && <0.6,@@ -65,8 +65,8 @@ filepath >=1.2 && <1.5, monad-control >=1.0 && <1.1, mtl >=2.0 && <3.0,- resourcet >=1.2 && <1.3,- text >=0.2 && <1.3,+ resourcet >=1.2 && <1.4,+ text >=0.2 && <2.1, time >=1.4 && <1.13, transformers >=0.4 && <0.6, transformers-base@@ -97,14 +97,14 @@ else cpp-options: -DZIP_OS=3- build-depends: unix <2.8+ build-depends: unix <2.9 executable haskell-zip-app main-is: Main.hs hs-source-dirs: bench-app default-language: Haskell2010 build-depends:- base >=4.13 && <5.0,+ base >=4.15 && <5.0, filepath >=1.2 && <1.5, zip @@ -122,7 +122,7 @@ hs-source-dirs: tests default-language: Haskell2010 build-depends:- base >=4.13 && <5.0,+ base >=4.15 && <5.0, QuickCheck >=2.4 && <3.0, bytestring >=0.9 && <0.12, conduit >=1.3 && <1.4,@@ -133,7 +133,7 @@ filepath >=1.2 && <1.5, hspec >=2.0 && <3.0, temporary >=1.1 && <1.4,- text >=0.2 && <1.3,+ text >=0.2 && <2.1, time >=1.4 && <1.13, transformers >=0.4 && <0.6, zip