Skip to content

Commit

Permalink
Increase buffer to 1k - add tests (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZJONSSON authored May 11, 2024
1 parent 637df97 commit a6e0392
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Open/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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.11.5",
"version": "0.11.6",
"description": "Unzip cross-platform streaming API ",
"author": "Evan Oxfeld <eoxfeld@gmail.com>",
"contributors": [
Expand Down
21 changes: 21 additions & 0 deletions test/office-files.js
Original file line number Diff line number Diff line change
@@ -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()));
});
Binary file added testData/office/testfile.docx
Binary file not shown.
Binary file added testData/office/testfile.xlsx
Binary file not shown.

0 comments on commit a6e0392

Please sign in to comment.