Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get notified when done extracting? #9

Closed
callumlocke opened this issue Nov 20, 2014 · 5 comments
Closed

How to get notified when done extracting? #9

callumlocke opened this issue Nov 20, 2014 · 5 comments

Comments

@callumlocke
Copy link

I can't get the "DONE!" to print out here (even though tar-fs successfully extracts the whole tar):

fs.createReadStream('./my-file.tar')
  .pipe(tar.extract('./my-dir'))
  .on('error', function(err) {
    console.error('ERROR', err);
  })
  .on('end', function() {
    console.log('DONE!');
  });

I've also tried listening for finish instead of end (as I saw that name used in your tests) but that doesn't work either. Not sure what I'm doing...

@callumlocke
Copy link
Author

I worked out I need to listen for the finish event on the tar.extract() part instead:

fs.createReadStream('./my-file.tar')
  .pipe(
    tar.extract('./my-dir')
      .on('finish', function () {
        console.log('DONE!');
      })
  )
  .on('error', function (err) {
    console.error('ERROR', err);
  })
  .on('end', function () {
    console.log('THIS NEVER FIRES');
  });

The original stream's end event is never fired. I'm guessing this is because there are extra bytes at the end of the tar that tar.extract doesn't need to read, so it just stops listening for its data events? Don't know if this is a bug. Please close this if not.

@mafintosh
Copy link
Owner

The extract stream does not emit finish since it's a writable stream. The pack stream emits end though (since its readable)

@callumlocke
Copy link
Author

The extract stream does not emit finish since it's a writable stream.

? but finish does fire, in my example

@mafintosh
Copy link
Owner

doh. I meant:

The extract stream does not emit end since it's a writable stream. The pack stream emits end though (since its readable)

@callumlocke
Copy link
Author

ah cool :) so this is right then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants