From 9c8b2dfbeb14ae9dc5e445a8d8013f0490f7ccdc Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Sat, 17 May 2014 14:09:05 -0700 Subject: [PATCH] Remove the mtime for temp file. Prevent false negative cache Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes (github: creack) Upstream-commit: bcfe2ceffb1c4c7006570d4ba21ed2068bb448a1 Component: engine --- components/engine/server/buildfile.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/engine/server/buildfile.go b/components/engine/server/buildfile.go index 46f214eac7..b37053ac16 100644 --- a/components/engine/server/buildfile.go +++ b/components/engine/server/buildfile.go @@ -16,11 +16,13 @@ import ( "regexp" "sort" "strings" + "syscall" "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/daemon" "github.com/dotcloud/docker/nat" "github.com/dotcloud/docker/pkg/symlink" + "github.com/dotcloud/docker/pkg/system" "github.com/dotcloud/docker/registry" "github.com/dotcloud/docker/runconfig" "github.com/dotcloud/docker/utils" @@ -563,6 +565,11 @@ func (b *buildFile) CmdAdd(args string) error { } tmpFile.Close() + // Remove the mtime of the newly created tmp file + if err := system.UtimesNano(tmpFileName, make([]syscall.Timespec, 2)); err != nil { + return err + } + origPath = path.Join(filepath.Base(tmpDirName), filepath.Base(tmpFileName)) // Process the checksum @@ -570,8 +577,8 @@ func (b *buildFile) CmdAdd(args string) error { if err != nil { return err } - tarSum := utils.TarSum{Reader: r, DisableCompression: true} - if _, err := io.Copy(ioutil.Discard, &tarSum); err != nil { + tarSum := &utils.TarSum{Reader: r, DisableCompression: true} + if _, err := io.Copy(ioutil.Discard, tarSum); err != nil { return err } remoteHash = tarSum.Sum(nil)