-
Notifications
You must be signed in to change notification settings - Fork 513
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
Corrupt zip file created using BlobReader on File object #508
Comments
One misconception I had is that compression would be off (level 0) by default; however, the default setting is 5. I have discovered that setting it to 0 rectifies the problem, but am still uncertain as to why having the default (and perhaps any non-zero) compression level would result in archive corruption. Is there a correlated option for either the BlobWriter or the |
Thank you for the bug report. I think I was able to reproduce the issue. It looks like it happens only when importing The tests below show the issue. The only difference is how |
I just realized my mistake, I didn't include the good script. I have to include |
It looks like you made the same mistake, see https://github.com/tmccoid-tech/extract-em/blob/main/module/zip.js. You should use https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-full.js instead (or https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-no-worker-deflate.min.js) when setting I think it's still a bug in zip.js though. It should never create invalid zip files. Or it should at least warn the user in that case. I'll look into how to avoid this. |
Thanks for looking into this and providing a solution so quickly. I wonder if you might want to update the demo I referenced in the first comment to use zip-full.js rather than zip.js, and maybe set the compression level explicitly and provide a comment to the effect of "0 = no compression, 5 = default, 9 = max" or the like. |
The issue related to |
Using the example provided at https://github.com/gildas-lormeau/zip.js/blob/gh-pages/demos/demo-create-file.js, I implemented a basic zip routine for use in an extension/add-on for the Mozilla Thunderbird email client.
The zip file is being generated without apparent error, and opening the archive in Windows File Explorer (or WinRAR, for that matter) displays the expected files. However, these files are un-extractable, with WinRAR indicating a checksum error (file is corrupt) on any included file.
Here is an abstraction of the code I am using:
async function add(fileName, fileData, creationDate) {
const zipWriter = new zip.ZipWriter(
new zip.BlobWriter("application/zip"), { bufferedWrite: true, useCompressionStream: false }
);
await zipWriter.add(fileName, new zip.BlobReader(fileData),
{ creationDate: creationDate, useWebWorkers: false }
);
const result = await zipWriter.close();
return result;
}
The
fileData
parameter is a JavaScript File object.I feel as if I must be missing something basic here. Any guidance would be appreciated.
The text was updated successfully, but these errors were encountered: