From f544da33b3836ffed9cc0286cc79ab56b92c0c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20HOUZ=C3=89?= Date: Mon, 12 Apr 2021 23:57:57 +0200 Subject: [PATCH 1/3] 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). --- internal/provider/zip_archiver.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/provider/zip_archiver.go b/internal/provider/zip_archiver.go index 087d0d9f..2650a2df 100644 --- a/internal/provider/zip_archiver.go +++ b/internal/provider/zip_archiver.go @@ -61,8 +61,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) if a.outputFileMode != "" { filemode, err := strconv.ParseUint(a.outputFileMode, 0, 32) @@ -144,8 +145,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) if a.outputFileMode != "" { filemode, err := strconv.ParseUint(a.outputFileMode, 0, 32) From 1218f58db47a91708b6a73160f07ca6d5c3be071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20HOUZ=C3=89?= Date: Wed, 21 Jul 2021 21:25:31 +0200 Subject: [PATCH 2/3] refactor: replace setModTime by Modified --- internal/provider/zip_archiver.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/provider/zip_archiver.go b/internal/provider/zip_archiver.go index 2650a2df..c0888eb7 100644 --- a/internal/provider/zip_archiver.go +++ b/internal/provider/zip_archiver.go @@ -62,8 +62,7 @@ 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(oldestZipSupportedModTime) + fh.Modified = oldestZipSupportedModTime if a.outputFileMode != "" { filemode, err := strconv.ParseUint(a.outputFileMode, 0, 32) @@ -146,8 +145,7 @@ 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(oldestZipSupportedModTime) + fh.Modified = oldestZipSupportedModTime if a.outputFileMode != "" { filemode, err := strconv.ParseUint(a.outputFileMode, 0, 32) From 273acc968e122ec5fbe3d6010a0b92f0efcc6dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20HOUZ=C3=89?= Date: Wed, 21 Jul 2021 21:49:13 +0200 Subject: [PATCH 3/3] test: add modifed time test --- internal/provider/archive-dir.zip | Bin 466 -> 520 bytes internal/provider/archive-file.zip | Bin 166 -> 184 bytes internal/provider/zip_archiver_test.go | 17 +++++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/internal/provider/archive-dir.zip b/internal/provider/archive-dir.zip index b88214af33bd92826043583cbdb0976773ef63ee..448134cf7a3e03a48786502cb85978eed778d789 100644 GIT binary patch literal 520 zcmWIWW@Zs#-~d7f21Ou70AU7BhLY6c65W){A|w5@%$!t1y^@NO&=6JzMuuhQgt$(g z&{5&;^+2gCs+m~M>6bT+u@X$JBsgiYs#xgF$e ztmbNX>gol0oI9`Wc~+YdZu*`#@4rX^-3_uKz?+dtgc%Vw$o>L_4Ge5)1hMdi6uL>s ten2%T4#OnWP(e2d*}Wh?!@!otJus6nLLk7Kl?|kh83=CxX(>h!4*+}%Xk-8Y literal 466 zcmWIWW@Zs#-~d7f2E{HQ0SCfBR!M4ciEc_}k&%8{W=^W1UP(m>*U1w)VL;?@`iy6& z0SgNQ!~g#Q-s~J+fr4EkKrMVg96*Ah#+Zh(!3|9_kWV3OC@;*VAV(q_r{Srq7wB>B zyte0AZAQ4Ed)~bNA_dd}GC07Skx7IZ5dg@(00jUHENKL>umlIX0mv>!H6Rqj0I=85 k4M27s$YU_Dq;VCH33dU@n*rXeY#?c7AlwV2|AROT07x5NssI20 diff --git a/internal/provider/archive-file.zip b/internal/provider/archive-file.zip index b2a7ea85c992d3350de84eddce675a32292842a6..34a7e1ae57488c25d587d43a47256ce2f963ce75 100644 GIT binary patch literal 184 zcmWIWW@Zs#-~d7f21Ou70A2=8hLY6c65X`SoK(G%ijvR}Rt83fW#@#rPM**S10oGi zUA;h$bLX`^&uTNWFfjc8AK=Z-vFFYEFH%5bM1VNJn~_O`8DT!M9LRha*wP4MVYe;7 So0SbD%Ls%nKspY@VE_Qt$t58G literal 166 zcmWIWW@Zs#-~d7f2E{HQ0SCN5R!M4ciEdhEPO4r>MG4o*6FOl)q~WQn7wB>Byte0A zZAKObhX4NqyxBSSym|jc3aCW{hy%PCnM9Zo#v;psjD>+EjUX0^B>~>7Y#>2KAhZV3 Ip&$+e0Ev