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

Zip file created by yazl not openable in Windows Explorer #53

Open
Matt4880 opened this issue Mar 28, 2019 · 6 comments
Open

Zip file created by yazl not openable in Windows Explorer #53

Matt4880 opened this issue Mar 28, 2019 · 6 comments

Comments

@Matt4880
Copy link

I'm using Yazl 2.5.1 as the final step of a Node-based build process to package my application. We occasionally find that the files produced will not open in native Windows Explorer (usually Win10) with Windows complaining that 'the compressed (zipped) folder '***' is invalid'

I am, however, able to open the archive using 7zip (v16.02)

The snippet of code I'm using to zip is

    var yazl = require("yazl");
    var zipfile = new yazl.ZipFile();
    zipfile.addFile(outputFilePath, setupFilename);
    zipfile.outputStream.pipe(fs.createWriteStream(outputFilePath.replace(/\.exe$/,'.zip')));

where variables outputFilePath, setupFilename have been already defined.

fs is using fs-extra

@thejoshwolfe
Copy link
Owner

Corrupt zipfile bugs usually happen when you don't wait for the operation to finish before trying to read it. I don't know if that's what's happening here; I don't see anything wrong with the code you posted.

Is it possible to share a zipfile that demonstrates the incompatibility? I might be able to spot something wrong with it by examining the binary file.

I've tested unzipping yazl-created zipfiles with the Windows 7 compressed folder utility before, so it's supposed to work. (The Mac Archive Utility has known issues, by contrast.)

@Matt4880
Copy link
Author

Any way I can send you a link? It's around 25Mb, so going via Google Drive prob works best

@thejoshwolfe
Copy link
Owner

[email protected]

@thejoshwolfe
Copy link
Owner

thejoshwolfe commented Mar 31, 2019

It does appear that the file is prematurely truncated. There's no Central Directory, which is supposed to come at the end of the file. I'm not sure what 7-Zip is doing to recover from that kind of corruption, but the standard linux command line program unzip is also not able to read it.

The stream created by fs.createWriteStream(outputFilePath.replace(/\.exe$/,'.zip')) will emit a 'close' event when the file has been completed. It's necessary to wait for that event on Windows before trying to do anything with it (and on posix, you really only need to wait for the 'finish' event, but the 'close' event is ok there too.) This is not yazl-specific; this is just how streams work in Node.

@Matt4880
Copy link
Author

Matt4880 commented Apr 1, 2019 via email

@ricky11
Copy link

ricky11 commented May 11, 2020

did you fix this matt

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

3 participants