fix: set modTime to current in snowball if archive shows empty (#16482)

This commit is contained in:
Klaus Post 2023-01-26 17:50:35 +01:00 committed by GitHub
parent 8fa80874a6
commit 027ff0f3a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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 {