From 027ff0f3a878436fcefc95a0a94d79e85f88511b Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 26 Jan 2023 17:50:35 +0100 Subject: [PATCH] fix: set modTime to current in snowball if archive shows empty (#16482) --- cmd/untar.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/untar.go b/cmd/untar.go index 4d6698aeb..143462483 100644 --- a/cmd/untar.go +++ b/cmd/untar.go @@ -30,6 +30,7 @@ import ( "path" "runtime" "sync" + "time" "github.com/cosnicolaou/pbzip2" "github.com/klauspost/compress/s2" @@ -259,6 +260,12 @@ func untar(ctx context.Context, r io.Reader, putObject func(reader io.Reader, in continue } + // If zero or earlier modtime, set to current. + // Otherwise the resulting objects will be invalid. + if header.ModTime.UnixNano() <= 0 { + header.ModTime = time.Now() + } + // Sync upload. rc := disconnectReader{r: tarReader} if err := putObject(&rc, header.FileInfo(), name); err != nil {