Skip to content

Commit f544da3

Browse files
author
Sébastien HOUZÉ
committed
fix: prefer to set mod time to oldest allowed by zip
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).
1 parent 150c3dc commit f544da3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/provider/zip_archiver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ func (a *ZipArchiver) ArchiveFile(infilename string) error {
6161
}
6262
fh.Name = filepath.ToSlash(fi.Name())
6363
fh.Method = zip.Deflate
64+
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
6465
// fh.Modified alone isn't enough when using a zero value
65-
fh.SetModTime(time.Time{})
66+
fh.SetModTime(oldestZipSupportedModTime)
6667

6768
if a.outputFileMode != "" {
6869
filemode, err := strconv.ParseUint(a.outputFileMode, 0, 32)
@@ -144,8 +145,9 @@ func (a *ZipArchiver) ArchiveDir(indirname string, excludes []string) error {
144145
}
145146
fh.Name = filepath.ToSlash(relname)
146147
fh.Method = zip.Deflate
148+
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
147149
// fh.Modified alone isn't enough when using a zero value
148-
fh.SetModTime(time.Time{})
150+
fh.SetModTime(oldestZipSupportedModTime)
149151

150152
if a.outputFileMode != "" {
151153
filemode, err := strconv.ParseUint(a.outputFileMode, 0, 32)

0 commit comments

Comments
 (0)