bower / decompress-zip

Module that decompresses zip files
MIT License
102 stars 76 forks source link

Added progress events, w/ test #39

Closed prust closed 9 years ago

prust commented 9 years ago

We needed to give the user progress notifications when extracting large zips, so they don't give up or think it is stuck. It's a small change, but may prove useful for others.

I'm not super-familiar with the codebase or with promises, but I think this should do the trick. I added a test & it passes.

Note that if #37 reduces the number of files in the first test zip file (as requested in https://github.com/bower/decompress-zip/pull/32#issuecomment-55375832 ?), then the numTotalFiles variable in the test will need to be adjusted.

prust commented 9 years ago

Decompress-zip does not extract the files in order (due to parallel processing?), so the indexes I was getting from forEach() were not sequential, which is not very useful as an indicator of unzip progress. I changed the progress event in 2ab824c to return sequential fileIndexs.

The only downside is that this loses the actual index of the file that was just processed, which may have matched the index of the file in the array returned by .list().

prust commented 9 years ago

thanks @sindresorhus -- and thank you for all your work maintaining this project over the weekend, it is much appreciated.