Skip to content

Commit df8215f

Browse files
author
Sébastien HOUZÉ
committed
fix: prefer to set mod time to oldes 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 a441e58 commit df8215f

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
@@ -59,8 +59,9 @@ func (a *ZipArchiver) ArchiveFile(infilename string) error {
5959
}
6060
fh.Name = filepath.ToSlash(fi.Name())
6161
fh.Method = zip.Deflate
62+
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
6263
// fh.Modified alone isn't enough when using a zero value
63-
fh.SetModTime(time.Time{})
64+
fh.SetModTime(oldestZipSupportedModTime)
6465

6566
f, err := a.writer.CreateHeader(fh)
6667
if err != nil {
@@ -134,8 +135,9 @@ func (a *ZipArchiver) ArchiveDir(indirname string, excludes []string) error {
134135
}
135136
fh.Name = filepath.ToSlash(relname)
136137
fh.Method = zip.Deflate
138+
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
137139
// fh.Modified alone isn't enough when using a zero value
138-
fh.SetModTime(time.Time{})
140+
fh.SetModTime(oldestZipSupportedModTime)
139141

140142
f, err := a.writer.CreateHeader(fh)
141143
if err != nil {

0 commit comments

Comments
 (0)