Disable compression for known 0-byte files
This commit is contained in:
parent
1944997266
commit
e61bc7b897
@ -32,7 +32,7 @@ data ZipInfo = ZipInfo
|
|||||||
data ZipEntry = ZipEntry
|
data ZipEntry = ZipEntry
|
||||||
{ zipEntryName :: Either T.Text ByteString -- ^File name (in posix format, no leading slashes), either UTF-8 encoded text or raw bytes (CP437), with a trailing slash for directories
|
{ zipEntryName :: Either T.Text ByteString -- ^File name (in posix format, no leading slashes), either UTF-8 encoded text or raw bytes (CP437), with a trailing slash for directories
|
||||||
, zipEntryTime :: LocalTime -- ^Modification time
|
, zipEntryTime :: LocalTime -- ^Modification time
|
||||||
, zipEntrySize :: Maybe Word64 -- ^Size of file data (if known); checked on zipping and also used as hint to enable zip64
|
, zipEntrySize :: Maybe Word64 -- ^Size of file data (if known); checked on zipping and also used as hint to enable zip64. Disables compression for known 0-byte files.
|
||||||
, zipEntryExternalAttributes :: Maybe Word32 -- ^Host-dependent attributes, often MS-DOS directory attribute byte (only supported when zipping)
|
, zipEntryExternalAttributes :: Maybe Word32 -- ^Host-dependent attributes, often MS-DOS directory attribute byte (only supported when zipping)
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,9 @@ zipStream ZipOptions{..} = execStateC 0 $ do
|
|||||||
entry (ZipEntry{..}, zipData -> dat) = do
|
entry (ZipEntry{..}, zipData -> dat) = do
|
||||||
let usiz = dataSize dat
|
let usiz = dataSize dat
|
||||||
sdat = left ((C..| sizeCRC) . C.toProducer) dat
|
sdat = left ((C..| sizeCRC) . C.toProducer) dat
|
||||||
comp = zipOptCompressLevel /= 0 && all (0 /=) usiz
|
comp = zipOptCompressLevel /= 0
|
||||||
|
&& all (0 /=) usiz
|
||||||
|
&& all (0 /=) zipEntrySize
|
||||||
(cdat, csiz)
|
(cdat, csiz)
|
||||||
| comp =
|
| comp =
|
||||||
( ((`C.fuseBoth` (outputSize $ CZ.compress zipOptCompressLevel deflateWindowBits))
|
( ((`C.fuseBoth` (outputSize $ CZ.compress zipOptCompressLevel deflateWindowBits))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user