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

Is the usage of streams problematic? #41

Closed
adhanji8 opened this issue Feb 7, 2024 · 2 comments
Closed

Is the usage of streams problematic? #41

adhanji8 opened this issue Feb 7, 2024 · 2 comments

Comments

@adhanji8
Copy link

adhanji8 commented Feb 7, 2024

Sorry for creating an issue out of this, you can close it right after. I just wanted clarification regarding the usage of streams in this library.

Yauzl has a point regarding streams that said:
Follow the spec. Don't scan for local file headers. Read the central directory for file metadata. (see No Streaming Unzip API).

I noticed that this library uses Streams. Is this an implementation detail that differs from the original Yauzl, or are streams being used in a different way that doesn't break the spec? Apologies for the potentially stupid question, appreciate it!

@overlookmotel
Copy link
Owner

Hi. Interesting question.

This library does not accept the input ZIP file as a stream. It requires random access, for the reasons you've quoted.

It starts at the end of the ZIP file and works backwards to find the Central Directory.

But once the Central Directory is found, that directory identifies the start and end positions of each file in the ZIP. At that point, yauzl-promise switches to streams in order to read each individual file from the ZIP and stream it out to the user.

This is exactly how yauzl works too, and in no way violates the ZIP spec.

I hope that makes sense. If it does, please close the issue. But if it doesn't, feel free to ask more questions!

@adhanji8
Copy link
Author

adhanji8 commented Feb 7, 2024

Thank you for the amazing explanation and also for maintaining is incredible project. You are sincerely appreciated 🙏. Thank you.

@adhanji8 adhanji8 closed this as completed Feb 7, 2024
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