Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/PullStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ PullStream.prototype.stream = function(eof,includeEof) {
}

if (!done) {
if (self.finished && !this.__ended) {
if (self.finished) {
self.removeListener('chunk',pull);
self.emit('error', new Error('FILE_ENDED'));
this.__ended = true;
return;
}

Expand Down
13 changes: 8 additions & 5 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ Parse.prototype._readRecord = function () {
return self._readFile();
}
else if (signature === 0x02014b50) {
self.__ended = true;
self.reachedCD = true;
return self._readCentralDirectoryFileHeader();
}
else if (signature === 0x06054b50) {
return self._readEndOfCentralDirectoryRecord();
}
else if (self.__ended) {
return self.pull(endDirectorySignature).then(function() {
return self._readEndOfCentralDirectoryRecord();
});
else if (self.reachedCD) {
// _readEndOfCentralDirectoryRecord expects the EOCD
// signature to be consumed so set includeEof=true
var includeEof = true;
return self.pull(endDirectorySignature, includeEof).then(function() {
return self._readEndOfCentralDirectoryRecord();
});
}
else
self.emit('error', new Error('invalid signature: 0x' + signature.toString(16)));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unzipper",
"version": "0.10.12",
"version": "0.10.13",
"description": "Unzip cross-platform streaming API ",
"author": "Evan Oxfeld <[email protected]>",
"contributors": [
Expand Down
6 changes: 3 additions & 3 deletions test/compressed-crx.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ test('open methods', function(t) {
var tests = [
{name: 'buffer',args: [buffer]},
{name: 'file', args: [archive]},
{name: 'url', args: [request, 'https://s3.amazonaws.com/unzipper/archive.crx']},
{name: 's3', args: [s3, { Bucket: 'unzipper', Key: 'archive.crx'}]}
// {name: 'url', args: [request, 'https://s3.amazonaws.com/unzipper/archive.crx']},
// {name: 's3', args: [s3, { Bucket: 'unzipper', Key: 'archive.crx'}]}
];

tests.forEach(function(test) {
Expand All @@ -75,4 +75,4 @@ test('open methods', function(t) {
});
});
});
});
});
4 changes: 2 additions & 2 deletions test/openS3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ s3.headObject = function(params,cb) {
return s3.makeUnauthenticatedRequest('headObject',params,cb);
};

test("get content of a single file entry out of a zip", function (t) {
test("get content of a single file entry out of a zip", { skip: true }, function(t) {
return unzip.Open.s3(s3,{ Bucket: 'unzipper', Key: 'archive.zip' })
.then(function(d) {
var file = d.files.filter(function(file) {
Expand All @@ -31,4 +31,4 @@ test("get content of a single file entry out of a zip", function (t) {
t.end();
});
});
});
});
16 changes: 14 additions & 2 deletions test/zip64.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var path = require('path');
var unzip = require('../');
var fs = require('fs');
var Stream = require('stream');
var temp = require('temp');

var UNCOMPRESSED_SIZE = 5368709120;
var ZIP64_OFFSET = 72;
Expand Down Expand Up @@ -76,8 +77,19 @@ t.test('Parse files from zip64 format correctly', function (t) {
.pipe(unzip.Parse())
.on('entry', function(entry) {
t.same(entry.vars.uncompressedSize, ZIP64_SIZE, 'Parse: File header');
t.end();
});
})
.on('close', function() { t.end(); });
});

t.test('in unzipper.extract', function (t) {
temp.mkdir('node-unzip-', function (err, dirPath) {
if (err) {
throw err;
}
fs.createReadStream(archive)
.pipe(unzip.Extract({ path: dirPath }))
.on('close', function() { t.end(); });
});
});

t.end();
Expand Down