Reputation: 1079
I'm trying to extract a .tar file(packed from a directory) and then check the names of the files in the extracted directory. I'm using tar-fs to extract the tar file and then use fs.createReadStream to manipulate the data. Here's what I've got so far:
fs.createReadStream(req.files.file.path)
.pipe(tar.extract(req.files.file.path + '0'))
.on('error', function() {
errorMessage = 'Failed to extract file. Please make sure to upload a tar file.';
})
.on('entry', function(header, stream, callback) {
console.error(header);
stream.on('end', function() {
console.error("this is working");
});
})
.on('end', function() {
//the one did not get called
console.error('end');
})
;
I was hoping to extract the whole folder and then check the file names. Well, I haven't get that far yet..
To my understanding, I got a readable stream after the pipe. And a readable stream has an end event? My question is, why the end
event in the code is not called?
Thanks!
Upvotes: 8
Views: 6543