Giter Site home page Giter Site logo

adm-zip's People

Contributors

5saviahv avatar amilajack avatar askovpen avatar autokaka avatar aviadatsnyk avatar clavery avatar criyle avatar cthackers avatar dependabot[bot] avatar devsnd avatar enecciariatbl avatar fileformats avatar iacobnasca avatar jaalfaro avatar kevinao22 avatar kevincharm avatar kingmario avatar likev avatar lukemalcolm avatar nascaiacob avatar pierre-lehnen-rc avatar podviaznikov avatar robincodex avatar sabberworm avatar saqibmushtaq avatar tnir avatar undefined-moe avatar wushukai avatar yarsh avatar yfdyh000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adm-zip's Issues

Unzipping files with path errors

Trying to unzip to a folder that doesn't yet exist results in some path mess. This is what I'm doing:

zip.extractAllTo('dist/tmp/' + index + '/');

Produces this error:

fs.js:381
  return binding.mkdir(pathModule._makeLong(path),
                 ^
Error: ENOENT, no such file or directory '/Users/jza/dev/jquery-ui/dist/tmp/0/development-bundle/ui\/Users/jza/dev/jquery-ui/dist/tmp/0/development-bundle/ui'
    at Object.mkdirSync (fs.js:381:18)
    at /Users/jza/dev/adm-zip/util/utils.js:19:20
    at Array.forEach (native)
    at mkdirSync (/Users/jza/dev/adm-zip/util/utils.js:12:26)
    at Object.writeFileTo (/Users/jza/dev/adm-zip/util/utils.js:96:17)
    at /Users/jza/dev/adm-zip/adm-zip.js:346:23
    at Array.forEach (native)
    at Object.extractAllTo (/Users/jza/dev/adm-zip/adm-zip.js:340:26)
    at [object Object].<anonymous> (/Users/jza/dev/jquery-ui/grunt.js:499:8)
    at [object Object].emit (events.js:88:20)

Not the messed up path.

addLocalFile / addLocalFolder not flexible..

Hi.

I need to zip a directory, say, [test] to make a node.js runnable
The directory looks like

test\package.json, etc....
test\include1\ -- bunch of directories and files in here that all need be zipped
say,
test\include1\file1.txt
test\include1\dir1\file2.txt
test\exclude1\ -- bunch of directories files in here. this shouldn't be zipped.

To do this with addLocalFolder, I'd call addLocalFolder('test'), but this won't be good since 'exclude1' get zipped too and has to be delted
And it seems that i can't really use addLocalFile since it ignores the path...
(for example, test\include1\file1.txt will be zipped as 'file1.txt' at the top level...

Am I missing something here?

I'm thinking addLocalFolder should take an 'exclude pattern' parameter or addLocalFile should have a way that it keeps the path in the zip file..

zip.writeZip('newfile.zip') crashes

Hi.

I tried to use the latest version v0.4.3 of adm-zip to open an existing ZIP archive , add some new files via zip.addFile() and save the complete zip back to disk as a new file by providing a new path+filename.

But everytime the function zip.writeZip('/path/newfile.zip') crashes. The only information I get is an "undefined" string in the console.

I use arm-zip with Node.js v0.8.8. Is this a problem?

Sync published version with github

Please, sync published version state with github sourses

  1. It's 0.4.2 on github but 0.4.3 in npm
  2. npm version contains console.log calls, that write file names during conpress call (in zipEntry.js, not for warning). That not exists in github and should be removed from npm too, because that can conflict with loggers of parent projects.

PS. If you like make - here is example, that protects from unsync mistakes https://github.com/nodeca/argparse/blob/master/Makefile#L82

Out of memory parsing large ZIP file

Opening a 600 MB ZIP file with:
var zip = new AdmZip('600MB.zip');

will cause node.js on Windows to exit abnormally with exit code %ERRORLEVEL% of 3.

extractAllTo doesn't work.

I am using a Windows 7 Ultimate 64 bit machine with node.js v 0.6.13

When i rename a .docx file into a .zip file and try to open it via adm-zip, most of the methods like .getEntries() and .readAsText() work.

When I use .extractAllTo() however I am hit with the following.

zip.extractAllTo('./out', true)
'./out', true)
Error: oob
at Buffer.slice (buffer.js:517:26)
at decompress (R:\xampp\htdocs\phpdocx\experiment\node_modules\adm-zip\zipEntry.js:39:73)
at Object.getData (R:\xampp\htdocs\phpdocx\experiment\node_modules\adm-zip\zipEntry.js:193:13)
at R:\xampp\htdocs\phpdocx\experiment\node_modules\adm-zip\adm-zip.js:344:37
at Array.forEach (native)
at Object.extractAllTo (R:\xampp\htdocs\phpdocx\experiment\node_modules\adm-zip\adm-zip.js:342:26)
at repl:1:6
at REPLServer.eval (repl.js:80:21)
at Interface. (repl.js:182:12)
at Interface.emit (events.js:67:17)

undefined

typeof maintainEntryPath == "undefned"

in adm-zip.js, line 296:
maintainEntryPath = typeof maintainEntryPath == "undefned" ? true : maintainEntryPath;

you mistyped "undefined" with "undefned"

checksum failed

I zipped a folder in Ubuntu 11.10 64bit.

I tried to use getEntry function to get file content but got checksum failed error.

How can I help you to investigate the problem?:)

'CRC32 checksum failed' error for valid zip file

Working on build scripts for jQuery UI, I'm getting a 'crc32 checksum failed' error on a otherwise valid zip file. Extracting that file with unzip or the built-in OSX utility works fine.

To get a copy of the zip file in question, go to http://jqueryui.com/download and click Download on the right side.

Here's my simple script to test this:

var AdmZip = require('adm-zip');
var fs = require('fs');
fs.mkdirSync('tmp');
var zip = new AdmZip('jquery-ui-1.8.18.custom.zip');
zip.extractAllTo('tmp');

The mkdirSync call is necessary due to #2.

Before outputting the error the script actually manages to extract the index.html file.

extractAllTo with a non-existing directory fails

Trying to extract a zip file to a directoy that doesn't exist yet fails:

TypeError: Cannot call method 'makeDir' of undefined
    at Object.writeFileTo (/Users/jza/dev/zip-test/node_modules/adm-zip/util/utils.js:77:31)

Changing exports.Utils.makeDir to module.exports.makeDir just causes another error, apparently the path resolving in mkdirSync is buggy.

Bad CRC on some binary files

adm-zip deflate some binary file with a bad crc.
This files can't be inflate with 3th part software (as 7z).
I'm using windows 7 64 bit.
node v0.10.13

This is my simple script:


var AdmZip = require('adm-zip');
var zip = new AdmZip();
zip.addLocalFile("./input_image3.jpg", "/");
zip.writeZip("test.zip");


and this the jpg that i use for the test:
input_image3

Compress program file problem

In Linux, I compressed a program file [Type: executable(application/x-executable) ].
After I extract it , the file is no longer a executable program.

High usage of RAM while extracting archive

I am currently writing on a tool to unzip archives using your module and I just recognised the very heavy usage of RAM.
To extract an archive of about 11MB, my node.exe uses about 250MB of RAM.
I experienced this with Node v0.10.5 on different machines running Windows7 or Windows8 using different archives of nearly the same size in total (might have been a few KB more or less on different archives), and with files of different filesizes within the archives (between 1KB and 1.8MB per file), the RAM-usage has always been nearly the same.

My code:

var AdmZip = require('adm-zip');

var archivePath = 'any-path.zip';
var extractPath = 'another-path';

var zip = new AdmZip(archivePath);
zip.extractAllTo(extractPath);

how i can use it with phonegap??

i am beginner in javascript.
I have a phonegap application which will need to take a zip archive of a webpage, unzip it, and display the output.
Anyone tell me how to use this plugin??
Thank for reading

Unzip crashes

Tried unzipping a 64MB zip file, the following error was thrown:
FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of memory

invalid archive generated

I used adm-zip to produce a zip archive ( I changed the code to only store the files, no compression ). but the output is invalid:

var zip = new AdmZip();

zip.addFile('node_modules/test/index.js','console.log("me")');
var out = path.resolve("./test3.zip");
zip.writeZip(out);

here is the generated output.

http://ge.tt/5yqSXdF

CRC32 checksum failed, different from the previous issue

Similar to this issue, I am getting a CRC32 checksum failed error while trying to unzip this file. I have the latest [email protected] version installed.

Extracting that file with unzip or the built-in OSX utility works fine.

Similar to the previous issue, here is the code to reproduce the error:

var AdmZip = require('adm-zip');
var fs = require('fs');
fs.mkdirSync('tmp');
var zip = new AdmZip('205555.zip');
zip.extractAllTo('tmp');

Note that the old issue has been fixed when I run it on my machine (that is, the jquery-ui-1.8.18.custom.zip can be now fully extracted).

Bad output

Trying to compress a folder, this is my test script:

var AdmZip = require('adm-zip');
var zip = new AdmZip();
zip.addLocalFolder('./dist');
zip.writeZip('./output.zip');

The dist folder contains a few files. The script runs without errors and outputs a output.zip file in the right location. Trying to decompress that with the built-in tool on OSX, the only output I get is a output.zip.cpgz file. Trying to uncompress that yields a output 2.zip, which again produces a cpgz file and so forth.

Can't tell what I'm missing, so hoping for help here. Let me know if you need specific information or a copy of the output.

error: invalid compressed data to inflate (using example from README)

using Node v 0.8.2 and adm-zip 0.1.5, and following the tutorial in the README, I am currently unable to zip when using buffers to add entries to the archive:

var AdmZip = require('adm-zip');
undefined
var zip = new AdmZip();
undefined
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
undefined
zip.writeZip('/private/tmp/example.zip')
undefined

/private/tmp $ unzip example.zip
Archive: example.zip
inflating: test.txt
error: invalid compressed data to inflate

async support

I don't see many documented callbacks? How would I get an asynchronous completion notification on operations?

Really liking this module otherwise, keen to use it.

extractAllTo UNC path

I am currently unable to figure out how to get files unpacked to a windows UNC folder path. Everything including the node server is Windows.

Zipping subfolded files results in folders

Files of subfolders are folders instead of files in zip file

package.json

{
  "name": "test",
  "version": "0.1.0",
  "devDependencies": {
    "adm-zip": "0.1.4"
  }
}

src/test.txt:

hello world

grunt.js:

module.exports = function( grunt )
{
  grunt.initConfig({
    zip: {
      dist: {
        src: 'src/**/*',
        dest: 'test.zip'
      }
    }
  });

  grunt.registerMultiTask( 'zip', 'Create a zip file', function()
  {
    var files = grunt.file.expandFiles( this.file.src );
    grunt.log.writeln( 'Creating zip file ' + this.file.dest );

    var fs = require( 'fs' );
    var AdmZip = require( 'adm-zip' );
    var zip = new AdmZip();

    files.forEach( function( file )
    {
      grunt.verbose.writeln( 'Zipping ' + file );
      zip.addFile( file, fs.readFileSync( file ) );
    });

    zip.writeZip( this.file.dest );
    grunt.log.writeln( 'Wrote ' + files.length + ' files to ' + this.file.dest );
  });

  grunt.registerTask( 'default', 'zip' );
};

test.zip:

- src
|- test.txt (folder instead of file)

EDIT: added this code after line 249 in adm-zip.js:

console.log(entry.toString());

and got this output:

{
        "entryName" : "src/test.txt",
        "name" : "test.txt",
        "comment" : "",
        "isDirectory" : false,
        "header" : {
                "made" : 10,
                "version" : 10,
                "flags" : 0,
                "method" : STORED (0),
                "time" : 1080181346,
                "crc" : 0x8BD69E52,
                "compressedSize" : 11 bytes,
                "size" : 11 bytes,
                "fileNameLength" : 12,
                "extraLength" : 0 bytes,
                "commentLength" : 0 bytes,
                "diskNumStart" : 0,
                "inAttr" : 438,
                "attr" : 438,
                "offset" : 0,
                "entryHeaderSize" : 58 bytes
},
        "compressedData" : 
        "data" : <11 bytes buffer>
}

CRC32 checksum failed

Similar to issues #12, #13, and #15 , I'm getting repeating characters on simple text files I'm extracting. The repeating character changes on each file. I even tried the readAsText method, and it's showing the same issue.

You can get the zip file here.

(also, I noticed this as well path.existsSync is now called fs.existsSync.. it didn't cause a real issue, more of a warning)

on build v0.1.9 and node v0.8.21

Files always end with repeating characters

I'm unzipping a 23KB zip file like this:

var zip = new AdmZip(zipBuffer);
zip.readAsText("actors.xml");

But the output ends with a repeating a like this:

 <BannerPath>graphical/79349-g17.jpg</BannerPath>\n  <BannerType>series</BannerType>\n  <BannerType2>graphical</BannerType2>\n  <Language>en</Language>\n  <Rating>1.0000</Rating>\n  <RatingCount>2</RatingCount>\n</Banner>\n<Banner>\n  <id>90161111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

or like this:

<SortOrder>3</SortOrder>\n</Actor>\n<Actor>\n  <id>130301</id>\n  <Image>actors/130301.jpg</Image>\n  <Name>John Lithgaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

It happens to two different files in the same zip.

WinRar cannot extract created zip files: CRC error

adm-zip can create and extract from it's own zip files but if I try to extract the files by using venerable WinRar I get a CRC error:

!   D:\tsd\tsd-origin\repo\repository_v2.zip: CRC failed in repository_v2.json. The file is corrupt

This is on Windows Vista 64 using node v0.10.10 and adm-zip 0.4.3 from NPM.

Node.js example contains zipped folder instead of file

For me the node.js compression example on ''ADM-ZIP-Introduction' on the wiki produces readable zip but with an empty folder named 'test.txt' instead of the 'test.txt' file.

I got adm-zip from npm today, it's package.json says 0.1.8 and this was on windows vista 64bit, my node.js is 0.8.14 x64 and I unzip using good ol' WinRar.

My code:

var zip = new Zip();
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");    
zip.writeZip(path + '/package.zip');`

Unable to extract zip with extra fields present in local file header

A ZIP containing files created with extra fields present in their local file header (such as universal time, and Unix UID/GID) cannot be properly extracted with extractEntryTo or extractAllTo methods.

I believe the fix is to replace the following line in zipFile.js:

entry.setCompressedData(buf.slice(entry.header.offset, entry.header.offset + Utils.Constants.LOCHDR + entry.header.compressedSize + entry.entryName.length));

with:

entry.setCompressedData(buf.slice(entry.header.offset, entry.header.offset + Utils.Constants.LOCHDR + entry.header.compressedSize + entry.entryName.length + buf.readUInt16LE(entry.header.offset + Utils.Constants.LOCEXT)));

Zip won't be created

Running my grunt build mechanism won't create a zip file...

package.json:

{
  "name": "test",
  "version": "0.1.0",
  "devDependencies": {
    "adm-zip": "0.1.4"
  }
}

grunt.js:

module.exports = function( grunt )
{
  grunt.initConfig({
    zip: {
      dist: {
        src: 'test.txt',
        dest: 'test.zip'
      }
    }
  });

  grunt.registerMultiTask( 'zip', 'Create a zip file', function()
  {
    var files = grunt.file.expandFiles( this.file.src );
    grunt.log.writeln( 'Creating zip file ' + this.file.dest );

    var fs = require( 'fs' );
    var AdmZip = require( 'adm-zip' );
    var zip = new AdmZip();

    files.forEach( function( file )
    {
      grunt.verbose.writeln( 'Zipping ' + file );
      zip.addFile( file, fs.readFileSync( file ) );
    });

    zip.writeZip( this.file.dest );
    grunt.log.writeln( 'Wrote ' + files.length + ' files to ' + this.file.dest );
  });

  grunt.registerTask( 'default', 'zip' );
};

test.txt:

Hello world

Output on running grunt -v:

Initializing
Command-line options: --verbose

Registering built-in tasks.
Loading "concat.js" tasks and helpers...OK
Tasks: concat
Helpers: concat
Loading "init.js" tasks and helpers...OK
Tasks: init
Helpers: prompt, prompt_for_obj, prompt_for, git_origin, github_web_url
Loading "lint.js" tasks and helpers...OK
Tasks: lint
Helpers: lint
Loading "min.js" tasks and helpers...OK
Tasks: min
Helpers: uglify, gzip, min_max_info
Loading "misc.js" tasks and helpers...OK
Helpers: config, json, strip_banner, file_strip_banner, banner
Loading "qunit.js" tasks and helpers...OK
Tasks: qunit
Loading "server.js" tasks and helpers...OK
Tasks: server
Loading "test.js" tasks and helpers...OK
Tasks: test
Loading "watch.js" tasks and helpers...OK
Tasks: watch

Reading "grunt.js" config file...OK
Initializing config...OK
Loading "grunt.js" tasks and helpers...OK
Tasks: zip, default

No tasks specified, running default tasks.
Running tasks: default

Running "default" task

Running "zip" task

Running "zip:dist" (zip) task
Verifying property zip.dist exists in config...OK
Creating zip file test.zip
Zipping test.txt
Wrote 1 files to test.zip

Done, without errors.

But there's no test.zip - nowhere...

bad CRC when unzipping

I keep running into an issue where the zip files I create are unable to be unzipped without CRC errors. I am creating an XML file from JSON which I am then trying to zip and email. Each part of this process is all being done in buffer. At no point have I written anything out to disk yet. When the XML files are small (read: less than 1k in size), there's no problem. Once the XML files start to get bigger in size, every zip file has an invalid CRC and can't be extracted properly without corruption.

I can't narrow down where the problem might be, except for maybe the size issue as that's the only time there's a change in the file that's being zipped where I've seen the CRC error occur.

Corrupted PNG files

Hey -- I'm ending up with corrupted PNG files when I use adm-zip, since PNGs are already in effect compressed. When I unzip the file that adm-zip crates, my PNGs are zero bytes.

:(

Essentially I'd like to include the PNG in the archive but not actually compress it. Possible?

Right now I'm just using addLocalFolder to add my src directory

I'm building apps for samsung TVs, so everything needs to be inside of one zip file for the platform to decompress.

thanks!!

new Zip(buffer)

I'm writing an app that needs to deal with zip files recursively nested within zip files. It would be great to be able to inflate the buffer in memory to get another buffer and then pass the inflated buffer to another call to new Zip(...) so that I can recursively unzip files all within memory, without needed any disk I/O.

It looks like the latest source in GitHub has the ability to do this, but it's not published on NPM. Is support for this planned? Will it be available in NPM soon?

Thanks! And thanks for a very useful library.

Dave

Async deflate does not build results properly

When doing the deflate in an async process, the results of each deflate of a chunk are returned to the callback instead of combining the chunks and then returning the full deflated buffer

not unzipped an empty directory

I have a zip archive:

directory images contains 1 image file
directory css contains 2 css files
directory js - empty
index.html

when I tried unzip this archive with extractAllTo I lost a directory js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.