From 015608e6a784beb145ba65185c1eb35343d55e01 Mon Sep 17 00:00:00 2001 From: Troy Ready Date: Mon, 5 Apr 2021 13:38:22 -0700 Subject: [PATCH] Fix central directory file header CRC32 Archives are currently being created with an empty CRC value (`00000000`), which causes validation errors on extraction (non-zero exit codes using `unzip` on Debian, and `Lambda was not able to unzip the file` errors on AWS Lambda). Fixes: #13 --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f686240..43ff15a 100644 --- a/index.js +++ b/index.js @@ -150,7 +150,7 @@ class Zipfile { } else { const directoryTempl = this.fileCentralDirTempl; const filenameBuffer = fromBuffer(file.relativePath) - directoryTempl.writeUIntLE(file.checksum, 16, 4); //crc-32 + directoryTempl.writeUIntLE(parseInt(file.checksum.toString('hex'), 16), 16, 4); //crc-32 directoryTempl.writeInt32LE(file.compressedSize, 20); //compressedSize directoryTempl.writeInt32LE(file.uncompressedSize, 24); //uncompressedSize directoryTempl.writeInt16LE(filenameBuffer.length, 28); //filename length @@ -202,4 +202,4 @@ const zip = (dir, destination, options, callback) => { }) } -module.exports = zip \ No newline at end of file +module.exports = zip