Merge pull request #3589 from tonistiigi/truncate-time

archive: truncate modification time
This commit is contained in:
Michael Crosby 2019-08-28 15:40:04 -04:00 committed by GitHub
commit 985bba61ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -504,6 +504,12 @@ func (cw *changeWriter) HandleChange(k fs.ChangeKind, p string, f os.FileInfo, e
hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode)))
// truncate timestamp for compatibility. without PAX stdlib rounds timestamps instead
hdr.Format = tar.FormatPAX
hdr.ModTime = hdr.ModTime.Truncate(time.Second)
hdr.AccessTime = time.Time{}
hdr.ChangeTime = time.Time{}
name := p
if strings.HasPrefix(name, string(filepath.Separator)) {
name, err = filepath.Rel(string(filepath.Separator), name)