I want to modify a tar.gz file in nodejs with tar_stream. I follow the procedure described in label "Modifying existing tarballs" but when my tar.gz is a little bigger(e.x. 20kb), it doesn't work. I noticed that every file of tar.gz is transferred to 'pack' and after some additions the pack memory is not enough to add the next files. For example, even if the tar contains 10 files and the memory of the pack is sufficient for the first 7, the process is never completed and so the extract on finish does not execute. How can I solve this problem?
An example of my code:
const checkEntries = tarStream => new Promise((resolve, reject) => {
const extract = tar.extract();
const pack = tar.pack();
tarStream.pipe(gunzip()).pipe(extract);
extract.on('entry', (header, stream, next) => {
stream.pipe(pack.entry(header, next));
stream.resume();
});
extract.on('finish', () => {
pack.finalize();
resolve();
}
reject()
);
});
});