Fixed file modified time not changing on Windows

Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 40b77af234319f02029368732249c2de0babb380
Component: engine
This commit is contained in:
Darren Stahl
2015-10-01 10:45:32 -07:00
parent cca18b2305
commit 5b5431a0c1
16 changed files with 412 additions and 45 deletions
@@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"syscall"
"time"
"github.com/docker/docker/pkg/system"
)
@@ -149,13 +150,15 @@ func copyDir(srcDir, dstDir string, flags copyFlags) error {
}
}
ts := []syscall.Timespec{stat.Atim, stat.Mtim}
// syscall.UtimesNano doesn't support a NOFOLLOW flag atm, and
// system.Chtimes doesn't support a NOFOLLOW flag atm
if !isSymlink {
if err := system.UtimesNano(dstPath, ts); err != nil {
aTime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
mTime := time.Unix(int64(stat.Mtim.Sec), int64(stat.Mtim.Nsec))
if err := system.Chtimes(dstPath, aTime, mTime); err != nil {
return err
}
} else {
ts := []syscall.Timespec{stat.Atim, stat.Mtim}
if err := system.LUtimesNano(dstPath, ts); err != nil {
return err
}