adm-zip icon indicating copy to clipboard operation
adm-zip copied to clipboard

0 byte files throws an error on getDataAsync / decompress

Open scandela opened this issue 6 years ago • 0 comments

Hi,

I found this issue on the function decompress used by GetDataAsync that has been in previous versions but didn't throw any error because the errors were not managed on the returned callback.

But on 0.4.13 now the errors are properly treated on extractAllToAsync, and then the issue cause to throw an error when unzipping the file. (Only when the zip files contains a 0-byte file)

The specific change introduced on 0.4.13 is here (Line 480): https://github.com/cthackers/adm-zip/commit/3d6aee3e8d8c132327d6eef40c2760e40707c9e7

The problematic isue would be found on line number 51 on this file: https://github.com/cthackers/adm-zip/blob/master/zipEntry.js

if (compressedData.length === 0) { if (async && callback) callback(compressedData, Utils.Errors.NO_DATA);//si added error. return compressedData; }

Just removing the entire if block would be enough to avoid the error, but I'm not sure if this error can happen actually, and if that's the case, Are there any way to differentiate when a file has trully 0 bytes and when a file has been unzipped incorrectly with 0 bytes?

For the moment, I'm going to specfically use the previous build (0.4.7), as this version doesn't have the issue and it's working perfectly on my project.

Cheers

scandela avatar Jan 17 '19 13:01 scandela