I wrote the below piece of code to zip a file and then delete once the same is done.
At first instance it works fine , and create the zip.
But for 2nd instance it zips the new new file and also add the previous file to the bundle , so now in my zip i have 2 file.
Please note i am also deleting the files physically from disk.
Can you please confim on this if this a bug / or how can clear the cache / in-memory of ZIP before being called again.
const zip = require('node-zip')();
zip.file(`${resultFileName}`, fs.readFileSync(resultFilePath));
const data = zip.generate({ base64: false, compression: 'DEFLATE' });
fs.writeFileSync(path.join(resultDirectory, `${date}.zip`), data, 'binary');
if (fs.existsSync(resultFilePath)) {
fs.unlinkSync(resultFilePath);
}
if (fs.existsSync(path.join(resultDirectory, `${date}.zip`))) {
fs.unlinkSync(path.join(resultDirectory, `${date}.zip`));
}
Hello Team,
I wrote the below piece of code to zip a file and then delete once the same is done. At first instance it works fine , and create the zip. But for 2nd instance it zips the new new file and also add the previous file to the bundle , so now in my zip i have 2 file. Please note i am also deleting the files physically from disk. Can you please confim on this if this a bug / or how can clear the cache / in-memory of ZIP before being called again.