Skip to content

Commit

Permalink
Merge branch 'master' into bug-234-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cthackers authored Oct 11, 2018
2 parents ca2afb5 + 83d44ba commit 6306ee9
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 2,045 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ sudo: false
language: node_js

node_js:
- 8
- 6
- 4

cache:
directories:
Expand All @@ -13,3 +13,6 @@ cache:
install:
- npm i -g npm@latest
- npm install

script:
- npm test
19 changes: 14 additions & 5 deletions adm-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ module.exports = function (/*String*/input) {
readAsTextAsync: function (/*Object*/entry, /*Function*/callback, /*String - Optional*/encoding) {
var item = getEntry(entry);
if (item) {
item.getDataAsync(function (data) {
item.getDataAsync(function (data, err) {
if (err) {
callback(data, err);
return;
}

if (data && data.length) {
callback(data.toString(encoding || "utf8"));
} else {
Expand Down Expand Up @@ -358,7 +363,7 @@ module.exports = function (/*String*/input) {

var entryName = item.entryName;

var target = sanitize(targetPath, pth.resolve(targetPath, maintainEntryPath ? entryName : pth.basename(entryName)));
var target = sanitize(targetPath, maintainEntryPath ? entryName : pth.basename(entryName));

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

Utils.writeFileTo(pth.resolve(targetPath, maintainEntryPath ? childName : childName.substr(entryName.length)), content, overwrite);
Utils.writeFileTo(childName, content, overwrite);
});
return true;
}
Expand Down Expand Up @@ -470,8 +475,12 @@ module.exports = function (/*String*/input) {
callback(undefined);
return;
}
entry.getDataAsync(function (content) {
entry.getDataAsync(function (content, err) {
if (i <= 0) return;
if (err) {
callback(new Error(err));
return;
}
if (!content) {
i = 0;
callback(new Error(Utils.Errors.CANT_EXTRACT_FILE));
Expand Down
2 changes: 1 addition & 1 deletion headers/entryHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ module.exports = function () {
// modification time (2 bytes time, 2 bytes date)
data.writeUInt32LE(_time, Constants.CENTIM);
// uncompressed file crc-32 value
data.writeUInt32LE(_crc, Constants.CENCRC);
data.writeInt32LE(_crc & 0xFFFF, Constants.CENCRC, true);
// compressed size
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
// uncompressed size
Expand Down
Loading

0 comments on commit 6306ee9

Please sign in to comment.