node.js unzip modules extract only few files -
we've been experimenting various node unzip modules (adm-zip, unzip, extract-zip) unzip large zip files. in of these modules, notice zipping happens first time. node server running continuously, if there request leads unzipping given .zip file again, notice above modules extract of files , rest of files in zip missed. everytime node server killed , restarted, first unzipping happens correctly , subsequently not. reason this? have tried cleaning directory extracted files written once done processing them, every subsequent unzipping goes empty directory.
i had similar problem, , in case, root cause process getting terminated before extraction finished.
the key make sure perform code can result in garbage cleaning after have finished extraction. in case, calling window.location (electron framework) under erroneous assumption call extract() of unzip module synchronous).
here successful code me:
fs.createreadstream(fp).pipe(unzipper.extract({ "path": dirname }) .on('finish', function() { //extraction done, can cleanup or navigation here. window.location = 'listing.html'; }) .on('error', () => console.log("error")) )
perhaps late you, useful else myself in future.
Comments
Post a Comment