@@ -640,6 +640,7 @@ func untar(r io.Reader, dir string) (err error) {
640
640
return badRequest ("requires gzip-compressed body: " + err .Error ())
641
641
}
642
642
tr := tar .NewReader (zr )
643
+ loggedChtimesError := false
643
644
for {
644
645
f , err := tr .Next ()
645
646
if err == io .EOF {
@@ -684,14 +685,23 @@ func untar(r io.Reader, dir string) (err error) {
684
685
if n != f .Size {
685
686
return fmt .Errorf ("only wrote %d bytes to %s; expected %d" , n , abs , f .Size )
686
687
}
687
- if ! f .ModTime .IsZero () {
688
- if err := os .Chtimes (abs , f .ModTime , f .ModTime ); err != nil {
688
+ modTime := f .ModTime
689
+ if modTime .After (t0 ) {
690
+ // Clamp modtimes at system time. See
691
+ // golang.org/issue/19062 when clock on
692
+ // buildlet was behind the gitmirror server
693
+ // doing the git-archive.
694
+ modTime = t0
695
+ }
696
+ if ! modTime .IsZero () {
697
+ if err := os .Chtimes (abs , modTime , modTime ); err != nil && ! loggedChtimesError {
689
698
// benign error. Gerrit doesn't even set the
690
699
// modtime in these, and we don't end up relying
691
700
// on it anywhere (the gomote push command relies
692
701
// on digests only), so this is a little pointless
693
702
// for now.
694
- log .Printf ("error changing modtime: %v" , err )
703
+ log .Printf ("error changing modtime: %v (further Chtimes errors suppressed)" , err )
704
+ loggedChtimesError = true // once is enough
695
705
}
696
706
}
697
707
nFiles ++
0 commit comments