archiverjs / node-archiver

a streaming interface for archive generation
https://www.archiverjs.com
MIT License
2.76k stars 218 forks source link

Produce the same zip file all time #762

Open AlttiRi opened 2 months ago

AlttiRi commented 2 months ago

Currently, the hash of each zip archive is unique. Seems, archiver adds the archiving time in the zip file.

Is it possibly to skip this? I need the reproducible result.

For example, 7zip always generates the same zips for the same input.


I use that:

export async function zipDirectory(sourceDir, outPath) {
    const archive = archiver("zip");
    const writeStream = fs.createWriteStream(outPath);
    const readStream = archive.directory(sourceDir, "");
    await archive.finalize();
    await pipeline(readStream, writeStream);
}
AlttiRi commented 2 months ago

Alternatively, I would like to have an ability to get the result zip's CRC hash of the data inside it. I assume archiver computes this, but just not exposes.