I am zipping a folder and fingerprinting it with its shasum however this keeps changing on every zipping. Same with md5 any idea why? Is it working based on access time or something? Is there a way to keep it consistent? It used to be consistent when I was doing git archive into a zip, but now I am directly zipping.


I had a similar problem with tar archives. There the differences were caused by atime and/or ctime entries. My solution was to use

tar -c --format=ustar ...

so that the timestamps were no longer part of the archive. Furthermore IIRC standard tar (i.e. GNU tar) creates a string describing the archive itself, and this string contains a timestamp. I.e. even if the archive content does not change at all the digest changes. This may be similar with ZIP.

For ZIP it seems that you can use the option --no-extra / -X to avoid file timestamps to be written to the archive. I just tested that. Without this option I get different archives but with the option they are the same.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.