-
Notifications
You must be signed in to change notification settings - Fork 80
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
Invalid central directory file header signature #30
Comments
please provide an example zip file that gives this error. I'd be happy to look into it (however my schedule for the next few days might be busy). |
yauzl handles compressed zip files. it is being used by thousands of users every day. if you've found a bug, i would certainly like to know about it, so it can be fixed. |
@thejoshwolfe I'm sorry for the late respond. Thanks |
your zip file is broken. the 3 bytes you can see a clue about this when you use InfoZip:
If I were the author of InfoZip, I would not have said "No errors detected" anywhere in the output of this command, because your zipfile is actually not conformant to the spec. InfoZip seems to have error-recovery mechanisms to guess what you meant, and carry on from there with confidence that they guessed correctly. yauzl makes no such presumptions, and does not attempt to anticipate these kinds of mistakes. You can fix your zipfile with this command:
|
Hey @thejoshwolfe , when using unzip via terminal it decompressed successfully the file. Do you know any solution? |
do you know why the zipfile is being corrupted? if you could solve that, it would bypass any need for a workaround afterward. if not, you have a number of options in JavaScript to correct the offset alignments. one idea is to make a copy of the file excluding the first three bytes. you could do that with out of curiosity, what is your usecase, if you don't mind my asking? |
@thejoshwolfe thank you for answering. This zip file is an output of a software called Solidworks Composer. I can't fix that because this is the normal output. My app need to support those files. I will look into the workarounds you suggested and will try to make it work. |
does Solidworks Composer call the zip file a .sgm file? it might be informative for yauzl to provide example code that implements a RandomAccessReader that does the simple offset logic. currently, the only example of a RandomAccessReader is in test/test.js, which is not a very good example. |
Yes, the original file extension is smg. If it possible, I think it may be good to create an AutomaticRandomAccessReader that read the file extension and implements the RandomAccessReader in a seamless way. What do you think? |
You're trying to read a non zip file with a zip file library. You can't expect that to work.
It's not within the scope of yauzl to know what a "sgm" file is. |
@andrewrk Hey |
I'm most of the way through implementing an example that reads a zipfile from the middle of a file. this sort of thing would be useful to parse a zipfile in-place that is embedded in some other container archive format. I'm adding it to the unzip.js example. I still don't plan to have any automatic search for where the zipfile really begins, like InfoZip and apparently 7Zip and WinRAR have. but if you knew in advance that you were dealing with a .sgm file, you could do something like the way the example works to parse it correctly in-place. the important thing is that you tell yauzl where the zipfile really starts and stops. yauzl will not automatically go searching for it. All of this that I'm talking about would go in the example only. I'm not planning to add any features to yauzl that don't already exist. What I'm talking about is using a custom RandomAccessReader, which is what you would have to do as a user of yauzl. the example code should be instructive enough to help you do whatever you need to do to parse .sgm or any other file format that contains an embedded zipfile. |
Ok, |
@asaf050, let me know if that example gives you some insight into how to accomplish your goals. The
|
@thejoshwolfe Thank you. Works like a charm! |
Not sure if you're talking about the command line program, in which case you can't, or your application code that uses the yauzl library. In the latter case, yauzl doesn't do anything with the output except provide it to your code, so you can find calls to |
Hey,
I can't find any node package that handles compressed zip files...
Same error as
glebdmitriew/node-unzip-2#1
The text was updated successfully, but these errors were encountered: