-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prefer to set mod time to oldest allowed by zip #93
base: main
Are you sure you want to change the base?
fix: prefer to set mod time to oldest allowed by zip #93
Conversation
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Sébastien HOUZÉ seems not to be a GitHub user. Have you signed the CLA already but the status is still pending? Recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - this looks like a very sensible fix!
zip#FileHeader.SetModTime()
is marked as deprecated in the stdlib docs in favour of setting FileHeader.Modified
directly. Judging by recent changes to archive/zip I think it's worth switching to FileHeader.Modified
so we can remove the "fh.Modified alone isn't enough when using a zero value" comment added in #16.
Please also add an acceptance test that checks the modified time of the archived file. You could add this to TestZipArchiver_FileModified
or make a new test.
df8215f
to
5ce1bea
Compare
As spotted in https://www.mindprod.com/jgloss/zip.html > The format does not support dates prior to 1980-01-01 0:00 UTC . Avoid file dates 1980-01-01 or earlier (local or UTC time).
5ce1bea
to
273acc9
Compare
@kmoe I've made all requested changes, LGTM? |
What does it fix?
zip files generated by this plugin are great because if we produce a zip file of the same files in two distinct points in time it will produce a zip archive with exactly the same resulting hash ❤️.
But... in go
time.Time{}
is the zero time, the documentation if very clear on it:This leads to 2 major issues:
1980-01-01 0:00 UTC
so we potentialy generate archives not supported by any zip unarchiver 🤐.Notes
As spotted in https://www.mindprod.com/jgloss/zip.html:
I'm not sur to generate the given date the best way that can be done in go, by the way I've tested the compiled module on a real situation and it fixes the issue I'm facing 😉.