Merge pull request #1496 from pulumi/zip-dates

Use an even more reasonable modtime in ZIP entries
This commit is contained in:
Matthew Riley 2018-06-11 20:36:13 -07:00 committed by GitHub
commit 1b33dbea53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -959,10 +959,12 @@ func addNextFileToZIP(r ArchiveReader, zw *zip.Writer) error {
Method: zip.Deflate,
}
// Set a nonzero -- but constant -- modification time. Otherwise, some agents (e.g. Azure websites) can't extract the
// resulting archive. We use `SetModTime` for go1.9 compatibility.
// Set a nonzero -- but constant -- modification time. Otherwise, some agents (e.g. Azure
// websites) can't extract the resulting archive. The date is comfortably after 1980 because
// the ZIP format includes a date representation that starts at 1980. Use `SetModTime` to
// remain compatible with Go 1.9.
// nolint: megacheck
fh.SetModTime(time.Unix(0, 0))
fh.SetModTime(time.Date(1990, time.January, 1, 0, 0, 0, 0, time.UTC))
fw, err := zw.CreateHeader(fh)
if err != nil {