Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 985bba6

Browse files
Merge pull request #3589 from tonistiigi/truncate-time
archive: truncate modification time
2 parents a1579ee + 372472b commit 985bba6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

archive/tar.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ func (cw *changeWriter) HandleChange(k fs.ChangeKind, p string, f os.FileInfo, e
504504

505505
hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode)))
506506

507+
// truncate timestamp for compatibility. without PAX stdlib rounds timestamps instead
508+
hdr.Format = tar.FormatPAX
509+
hdr.ModTime = hdr.ModTime.Truncate(time.Second)
510+
hdr.AccessTime = time.Time{}
511+
hdr.ChangeTime = time.Time{}
512+
507513
name := p
508514
if strings.HasPrefix(name, string(filepath.Separator)) {
509515
name, err = filepath.Rel(string(filepath.Separator), name)

0 commit comments

Comments
 (0)