Skip to content

Commit

Permalink
fix: prefer to set mod time to oldes allowed by zip
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Sébastien HOUZÉ committed Apr 12, 2021
1 parent a441e58 commit df8215f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/provider/zip_archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ func (a *ZipArchiver) ArchiveFile(infilename string) error {
}
fh.Name = filepath.ToSlash(fi.Name())
fh.Method = zip.Deflate
oldestZipSupportedModTime, _ := time.Parse(time.RFC3339, "1980-01-01T00:00:00+00:00")
// fh.Modified alone isn't enough when using a zero value
fh.SetModTime(time.Time{})
fh.SetModTime(oldestZipSupportedModTime)

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

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

0 comments on commit df8215f

Please sign in to comment.