Skip to content

Commit 6306ee9

Browse files
authored
Merge branch 'master' into bug-234-fix
2 parents ca2afb5 + 83d44ba commit 6306ee9

14 files changed

+255
-2045
lines changed

Diff for: .travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ sudo: false
33
language: node_js
44

55
node_js:
6+
- 8
67
- 6
7-
- 4
88

99
cache:
1010
directories:
@@ -13,3 +13,6 @@ cache:
1313
install:
1414
- npm i -g npm@latest
1515
- npm install
16+
17+
script:
18+
- npm test

Diff for: adm-zip.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ module.exports = function (/*String*/input) {
113113
readAsTextAsync: function (/*Object*/entry, /*Function*/callback, /*String - Optional*/encoding) {
114114
var item = getEntry(entry);
115115
if (item) {
116-
item.getDataAsync(function (data) {
116+
item.getDataAsync(function (data, err) {
117+
if (err) {
118+
callback(data, err);
119+
return;
120+
}
121+
117122
if (data && data.length) {
118123
callback(data.toString(encoding || "utf8"));
119124
} else {
@@ -358,7 +363,7 @@ module.exports = function (/*String*/input) {
358363

359364
var entryName = item.entryName;
360365

361-
var target = sanitize(targetPath, pth.resolve(targetPath, maintainEntryPath ? entryName : pth.basename(entryName)));
366+
var target = sanitize(targetPath, maintainEntryPath ? entryName : pth.basename(entryName));
362367

363368
if (item.isDirectory) {
364369
target = pth.resolve(target, "..");
@@ -369,9 +374,9 @@ module.exports = function (/*String*/input) {
369374
if (!content) {
370375
throw Utils.Errors.CANT_EXTRACT_FILE;
371376
}
372-
var childName = sanitize(targetPath, child.entryName);
377+
var childName = sanitize(targetPath, maintainEntryPath ? child.entryName : pth.basename(child.entryName));
373378

374-
Utils.writeFileTo(pth.resolve(targetPath, maintainEntryPath ? childName : childName.substr(entryName.length)), content, overwrite);
379+
Utils.writeFileTo(childName, content, overwrite);
375380
});
376381
return true;
377382
}
@@ -470,8 +475,12 @@ module.exports = function (/*String*/input) {
470475
callback(undefined);
471476
return;
472477
}
473-
entry.getDataAsync(function (content) {
478+
entry.getDataAsync(function (content, err) {
474479
if (i <= 0) return;
480+
if (err) {
481+
callback(new Error(err));
482+
return;
483+
}
475484
if (!content) {
476485
i = 0;
477486
callback(new Error(Utils.Errors.CANT_EXTRACT_FILE));

Diff for: headers/entryHeader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ module.exports = function () {
213213
// modification time (2 bytes time, 2 bytes date)
214214
data.writeUInt32LE(_time, Constants.CENTIM);
215215
// uncompressed file crc-32 value
216-
data.writeUInt32LE(_crc, Constants.CENCRC);
216+
data.writeInt32LE(_crc & 0xFFFF, Constants.CENCRC, true);
217217
// compressed size
218218
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
219219
// uncompressed size

0 commit comments

Comments
 (0)