gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.38k stars 510 forks source link

Not working for several files #388

Closed asif-ca closed 1 year ago

asif-ca commented 1 year ago

If we select multiple files and if there is something wrong with some of the files ( Even all tested pdf files are correct but the library unable to read some of them) It throws an error and stops everything:

Please check all these files and test by dragging all files:

https://gildas-lormeau.github.io/zip.js/demos/demo-create-file.html 

Added table of content (21).pdf Added table of content (20).pdf Added table of content (19).pdf Added table of content (18).pdf Added table of content (17).pdf Added table of content (16).pdf Added table of content (15).pdf Added table of content (14).pdf Added table of content (13).pdf Copmcri-locked (6).pdf

gildas-lormeau commented 1 year ago

I think I cannot reproduce the issue you described because the demo does not trigger any error on my end when I try to add these files in a zip file. Can you give me more details about the error you're seeing?

asif-ca commented 1 year ago

Hi, Thanks for Confirmation!

Yes it worked correctly when I checked the demo in another PC, then realized I have about 2.5GB remaining space on c drive (in which my chrome is installed) on the PC I was facing an issue ( alert of undefined shows and everything stops means the download zip button did not get active)

I cleared more memory and it worked fine!

I integrated this library in a web application to zip user selected files but I am afraid that if the user has low memory (as this is browser-based) they will face same problems?

is there any workaround for this?

I can record a video if you are unable to replicate it on low memory PC (just alert show of undefinedand operation stops)

Thanks

gildas-lormeau commented 1 year ago

Interesting, I hadn't thought about this case and I didn't do any tests in these conditions. The demo is not really optimized to save memory. I think of 2 points in particular:

Therefore, you should avoid using Promise.all but rather iterate with a for ... of and remove the option bufferedWrite: true. Moreover, it would probably be better to use another class than BlobWriter (e.g. Uint8ArrayWriter) because nothing guarantees that the browser does not write the Blob on the disk.

gildas-lormeau commented 1 year ago

I'm closing this issue because it's not a bug but it will be converted to a discussion.