This successfully extracts the following corrupt archive, which fails to extract using other software, except when using Apple's Archive Utility (that's another mystery because even UNIX unzip reports CRC error).
In my opinion, archiver tools should verify content integrity by default. Therefore, when skipCRC32 is false, unzipItem as a one-shot helper should perform this default behavior by comparing extract return with CRC from each zip entry. Not to mention when calling this helper method, there is no other way for the caller to really step in and compare CRCs themselves; skipCRC32 == false should suggest that they want integrity checks performed after calculating CRCs. (Otherwise why would you want to calculate something that you can never get or use?)
Steps to Reproduce
Download the ZIP file above.
Extract with FileManager.default.unzipItem(at:to).
Expected Results
Method throws because the archive was corrupted.
Actual Results
Call completes and creates (corrupted) files in target directory, as if the archive was intact.
Thanks for reporting this - this was an oversight.
CRC32 checksums will be properly evaluated when using the FileManager convenience unzip method in the next release.
Summary
Extension method on
FileManager
currently ignores CRC return from the actual extract call.https://github.com/weichsel/ZIPFoundation/blob/bad07a8f3dfefb0cf9faa8f9c89b6a762c92ebb0/Sources/ZIPFoundation/FileManager%2BZIP.swift#L127
This successfully extracts the following corrupt archive, which fails to extract using other software, except when using Apple's Archive Utility (that's another mystery because even UNIX
unzip
reports CRC error).Printer Driver.zip
In my opinion, archiver tools should verify content integrity by default. Therefore, when
skipCRC32
isfalse
,unzipItem
as a one-shot helper should perform this default behavior by comparingextract
return with CRC from each zip entry. Not to mention when calling this helper method, there is no other way for the caller to really step in and compare CRCs themselves;skipCRC32 == false
should suggest that they want integrity checks performed after calculating CRCs. (Otherwise why would you want to calculate something that you can never get or use?)Steps to Reproduce
FileManager.default.unzipItem(at:to)
.Expected Results
Method throws because the archive was corrupted.
Actual Results
Call completes and creates (corrupted) files in target directory, as if the archive was intact.
Regression & Version
0.9.14
Related Link
None