Skip to content

Commit

Permalink
Allow decompress option for non-deflate compressed entries
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Apr 24, 2018
1 parent e0c5a94 commit 03c0996
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ ZipFile.prototype.openReadStream = function(entry, options, callback) {
}
}
if (options.decompress != null) {
if (!entry.isCompressed()) {
if (entry.compressionMethod === 0) {
throw new Error("options.decompress can only be specified for compressed entries");
}
if (!(options.decompress === false || options.decompress === true)) {
Expand Down Expand Up @@ -511,8 +511,10 @@ ZipFile.prototype.openReadStream = function(entry, options, callback) {
} else if (entry.compressionMethod === 8) {
// 8 - The file is Deflated
decompress = options.decompress != null ? options.decompress : true;
} else {
} else if (options.decompress == null || options.decompress) {
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
} else {
decompress = false;
}
var fileDataStart = localFileHeaderEnd;
var fileDataEnd = fileDataStart + entry.compressedSize;
Expand Down

0 comments on commit 03c0996

Please sign in to comment.