adm-zip icon indicating copy to clipboard operation
adm-zip copied to clipboard

api toBufferPromise not expected

Open zq0904 opened this issue 3 years ago • 1 comments

First of all, thank you for your contribution to this great project!

  const admZip = new AdmZip()
  await admZip.addLocalFolderPromise(path.resolve(__dirname, 'asd'), {})
  await admZip.writeZipPromise(path.resolve(__dirname, '4.zip'))
  console.log('contentHash1', getContentHash(await admZip.toBufferPromise())) // df15b1c7a53013d485dc6ee61e58cb10
  console.log('contentHash2', getContentHash(await new AdmZip(path.resolve(__dirname, '4.zip')).toBufferPromise())) // 0a4af6c708af8e737e57e2d117f93985
  console.log('contentHash3', getContentHash(await fse.readFile(path.resolve(__dirname, '4.zip')))) // 0a4af6c708af8e737e57e2d117f93985

Why is contentHash1 inconsistent with contentHash2 so that I have to bypass this API to avoid the problem?

I don't know how zip works, but I need to know the contentHash (Buffer) before the zip is formed, but with this library I have to print the ZIP and then read the Buffer in FS (because that's the only way Buffer is correct).

zq0904 avatar Jul 04 '22 10:07 zq0904

related to #440, I suspect

bennettellis avatar Jan 16 '23 19:01 bennettellis