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

Can't attach error handler #1

Open
BenV opened this issue Oct 6, 2018 · 0 comments
Open

Can't attach error handler #1

BenV opened this issue Oct 6, 2018 · 0 comments

Comments

@BenV
Copy link

BenV commented Oct 6, 2018

(Continuing discussion from thejoshwolfe/yauzl#69)

Since the ZIP files are now scanned during the call to open, I can no longer listen for error events from readEntry, and therefore I can't ignore ones I don't care about (such as absolute/relative paths). Instead, the error will be passed to the callback provided to the open method.

I am doing something like:

yauzl.open(zipPath, 
{ supportMacArchiveUtility: true, lazyEntries: true, autoClose: false }, 
function (err, zipfile) {
  if(err) return cb(err);
  zipfile.on('error', function() { // determine whether to ignore error });
  zipfile.on('entry', function() {...});
  zipfile.readEntry();
});

When supportMacArchiveUtility is true with the attached zip file containing an absolute path, I never have the opportunity to handle the error event.

I think you could defer scanning for the central directory until the first call to readEntry, but even then I'm not sure I could still ignore errors I don't care about with the way the events are being intercepted -- currently if I want to "ignore" an error I set errorEmitted back to false and perform another call to readEntry.

I was able to work around this in a fairly ugly fashion by adding an "error filter" function to a forked version of yauzl which allows me to ignore errors at that level, but it would be nice to not have to fork yauzl, particularly if yauzl-mac is designed to be a drop in replacement.

entry-error.zip

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

1 participant