adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.25k stars 479 forks source link

Recent ZipArchive changes destroy performance on all non-zip archives #106

Closed benshoof closed 8 years ago

benshoof commented 8 years ago

A critical bug has been recently introduced that causes SharpCompress to read and process the entirety of all non-zip archives when opening them. This affects both Archive and Reader APIs.

0f12a073af4486509dfd777da1854efb5dc571ee causes ZipArchive.IsZipFile() to scan the entire archive looking for a zip header instead of returning immediately after not finding it at the start. Since the first thing that ArchiveFactory.Open() and ReaderFactory.Open() do is call ZipArchvie.IsZipFile(), all non-zip archives pay this price. Even worse, the header search is CPU bound so it takes much longer than simply reading the entire file. Zip files open quickly though since they pass the test right away. The committer probably only tested this on zip files and small non-zip files.

This commit needs to be reverted.

adamhathcock commented 8 years ago

Can you do this for me? I'm fighting fires at work.