diff --git a/lib/Open/directory.js b/lib/Open/directory.js index 0ffae26..f3dcea5 100644 --- a/lib/Open/directory.js +++ b/lib/Open/directory.js @@ -214,9 +214,10 @@ module.exports = function centralDirectory(source, options) { .then(function(comment) { vars.comment = comment; vars.type = (vars.uncompressedSize === 0 && /[\/\\]$/.test(vars.path)) ? 'Directory' : 'File'; + var padding = options && options.padding || 1000; vars.stream = function(_password) { var totalSize = 30 - + 10 // add an extra buffer + + padding // add an extra buffer + (vars.extraFieldLength || 0) + (vars.fileNameLength || 0) + vars.compressedSize; diff --git a/package.json b/package.json index ec64ed2..22b688a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unzipper", - "version": "0.11.5", + "version": "0.11.6", "description": "Unzip cross-platform streaming API ", "author": "Evan Oxfeld ", "contributors": [ diff --git a/test/office-files.js b/test/office-files.js new file mode 100644 index 0000000..c0f51c4 --- /dev/null +++ b/test/office-files.js @@ -0,0 +1,21 @@ + +var test = require('tap').test; +var fs = require('fs'); +var path = require('path'); +var unzip = require('../'); +var il = require('iconv-lite'); +var Promise = require('bluebird'); + +test("get content a docx file without errors", async function (t) { + var archive = path.join(__dirname, '../testData/office/testfile.docx'); + + const directory = await unzip.Open.file(archive); + await Promise.all(directory.files.map(file => file.buffer())); +}); + +test("get content a xlsx file without errors", async function (t) { + var archive = path.join(__dirname, '../testData/office/testfile.xlsx'); + + const directory = await unzip.Open.file(archive); + await Promise.all(directory.files.map(file => file.buffer())); +}); \ No newline at end of file diff --git a/testData/office/testfile.docx b/testData/office/testfile.docx new file mode 100644 index 0000000..3c76419 Binary files /dev/null and b/testData/office/testfile.docx differ diff --git a/testData/office/testfile.xlsx b/testData/office/testfile.xlsx new file mode 100644 index 0000000..591f700 Binary files /dev/null and b/testData/office/testfile.xlsx differ