From 2937a64bbdf8f4793e101b648ab9374e88eb5177 Mon Sep 17 00:00:00 2001 From: matsnow Date: Wed, 21 Mar 2018 21:07:21 +0900 Subject: [PATCH] Add error handler to zipfile object --- index.js | 6 ++++++ test/broken.zip | Bin 0 -> 171 bytes test/test.js | 11 +++++++++++ 3 files changed, 17 insertions(+) create mode 100644 test/broken.zip diff --git a/index.js b/index.js index 8c193e4..682d401 100644 --- a/index.js +++ b/index.js @@ -32,6 +32,12 @@ module.exports = function (zipPath, opts, cb) { var cancelled = false + zipfile.on('error', function (err) { + if (err) { + cancelled = true + return cb(err) + } + }) zipfile.readEntry() zipfile.on('close', function () { diff --git a/test/broken.zip b/test/broken.zip new file mode 100644 index 0000000000000000000000000000000000000000..5aa6788ace4c4b13a1b914810aa7e0b31f376b5d GIT binary patch literal 171 zcmWIWW@h1H0D-odr9O({lWSRlY!K#PkYUKkPfyiLNh}Es;bdU`t-mSiFA$eja5FHn zd}U-{U=abTGc+