Skip to content

"invalid compressed data to inflate" on unzipping after addLocalFolder #102

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

Closed
kadishmal opened this issue Aug 27, 2014 · 10 comments · Fixed by #243
Closed

"invalid compressed data to inflate" on unzipping after addLocalFolder #102

kadishmal opened this issue Aug 27, 2014 · 10 comments · Fixed by #243

Comments

@kadishmal
Copy link

I create a new zip by adding a local directory as follows:

var zip = new AdmZip(symbolfile.oldSymbolfilePath),
    zipEntries = zip.getEntries(),
    bundleName,
    entry,
    match;

zipEntries.some(function(zipEntry) {
    match = zipEntry.entryName.match(/dSYMs\/(.+\.app\.dSYM)\/$/);

    if (match) {
        entry = zipEntry;
        return true;
    }
});

var newZip = new AdmZip(),
    tempDir = './tmp';

symbolfile.tempPath = path.resolve(path.join(tempDir, symbolfile.projectname, symbolfile.version, symbolfile.platform));
// Extract original ZIP to a temporary location.
zip.extractAllTo(symbolfile.tempPath);

newZip.addLocalFolder(path.join(symbolfile.tempPath, entry.entryName), bundleName);

console.log('Saving a new ZIP file to', symbolfile.targetPath);
newZip.writeZip(symbolfile.targetPath);

After a new zip file is written to a disk, I try to extract and it gives me the following error:

$ unzip BundleName.app.dSYM.zip
Archive:  /Users/user/BundleName.app.dSYM.zip
creating: BundleName.app.dSYM/Contents/
inflating: BundleName.app.dSYM/Contents/Info.plist
creating: BundleName.app.dSYM/Contents/Resources/
creating: BundleName.app.dSYM/Contents/Resources/DWARF/
inflating: BundleName.app.dSYM/Contents/Resources/DWARF/BundleName
error:  invalid compressed data to inflate
@tybenz
Copy link

tybenz commented Sep 4, 2014

I'm experiencing the exact same thing. Some files work when adding to a zip and then extracting.

There are some files, though that let me add them to the zip and write the zip, but when extracting the contents the files are empty.

Here is a specific file that is not working for me: http://awes0.me/hjkl-center.png

var fs = require( 'fs' );
var Zip = require( 'adm-zip' );

var zip = new Zip();
zip.addLocalFile( '/path/to/file.png' );
zip.extractAllTo( '/path/to/folder' ); // file.png is empty

// OR

var zip = new Zip();
zip.addFile( 'file.png', fs.readFileSync( '/path/to/file.png' ) );
zip.extractAllTo( '/path/to/folder' ); // file.png is empty

It's the same whether I extract programmatically, or write the zip and call unzip from the shell.

Any ideas?

@gullerya
Copy link

gullerya commented Sep 5, 2014

Hi,
I've experienced the same behavior and my conclusion is that it happens
with already compressed formats, probably something to do with length of
the compressed buffer...
Temporary workaround may be to use STORE mode (no compression), that worked.
On Sep 4, 2014 11:09 PM, "Tyler Benziger" notifications@github.com wrote:

I'm experiencing the exact same thing. Some files work when adding to a
zip and then extracting.

There are some files, though that let me add them to the zip and write the
zip, but when extracting the contents the files are empty.

Here is a specific file that is not working for me:
http://awes0.me/hjkl-center.png

var fs = require( 'fs' );var Zip = require( 'adm-zip' );
var zip = new Zip();zip.addLocalFile( '/path/to/file.png' );zip.extractAllTo( '/path/to/folder' ); // file.png is empty
// OR
var zip = new Zip();zip.addFile( 'file.png', fs.readFileSync( '/path/to/file.png' ) );zip.extractAllTo( '/path/to/folder' ); // file.png is empty

It's the same whether I extract programmatically, or write the zip and
call unzip from the shell.

Any ideas?


Reply to this email directly or view it on GitHub
#102 (comment).

@tybenz
Copy link

tybenz commented Sep 5, 2014

I switched to another module: https://github.com/ctalkington/node-archiver and it's working now.

@Egnus
Copy link

Egnus commented Sep 16, 2014

check if this fix that:
#100 (comment)

@marcohamersma
Copy link

Same problem for me, but that fix is not working unfortunately. Now returns EISDIR, illegal operation on a directory

@rainbow-alex
Copy link

Temporary workaround may be to use STORE mode (no compression), that worked.

To do so, I replaced Utils.Constants.DEFLATED with Utils.Constants.STORED in zipEntry.js on line 176. This worked fine for me.

@pixelOneZero
Copy link

@rainbow-alex Many, many thanks for the recommendation to use the constant STORED, instead of DEFLATED. It worked in my case.

@pixelOneZero
Copy link

Does anyone know if this will be accepted into the build as an official fix?

@mygoare mygoare mentioned this issue May 22, 2015
sridharrajs added a commit to sridharrajs/folder-zip that referenced this issue Mar 8, 2016

Verified

This commit was signed with the committer’s verified signature.
chemicL Dariusz Jędrzejczyk
2. invalid compressed data to inflate on unzipping after addLocalFolder #102 url cthackers/adm-zip#102
@nuest
Copy link

nuest commented Nov 17, 2016

Getting the same error today - any new workarounds? I'd rather not go into a file and change the whole library...

@terrisgit
Copy link

This is happening to us. Show stopper.

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

Successfully merging a pull request may close this issue.

9 participants