diff --git a/archive/changes.go b/archive/changes.go index 83bdcae7cf..a4076fc0ad 100644 --- a/archive/changes.go +++ b/archive/changes.go @@ -181,7 +181,7 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) { oldStat.Rdev != newStat.Rdev || // Don't look at size for dirs, its not a good measure of change (oldStat.Size != newStat.Size && oldStat.Mode&syscall.S_IFDIR != syscall.S_IFDIR) || - oldStat.Mtim != newStat.Mtim { + getLastModification(oldStat) != getLastModification(newStat) { change := Change{ Path: newChild.path(), Kind: ChangeModify, diff --git a/archive/diff.go b/archive/diff.go index 58d30466e3..f44991ecb5 100644 --- a/archive/diff.go +++ b/archive/diff.go @@ -83,8 +83,10 @@ func ApplyLayer(dest string, layer Archive) error { } for k, v := range modifiedDirs { - aTime := time.Unix(v.Atim.Unix()) - mTime := time.Unix(v.Mtim.Unix()) + lastAccess := getLastAccess(v) + lastModification := getLastModification(v) + aTime := time.Unix(lastAccess.Unix()) + mTime := time.Unix(lastModification.Unix()) if err := os.Chtimes(k, aTime, mTime); err != nil { return err diff --git a/archive/stat_darwin.go b/archive/stat_darwin.go new file mode 100644 index 0000000000..53ae9dee2f --- /dev/null +++ b/archive/stat_darwin.go @@ -0,0 +1,11 @@ +package archive + +import "syscall" + +func getLastAccess(stat *syscall.Stat_t) syscall.Timespec { + return stat.Atimespec +} + +func getLastModification(stat *syscall.Stat_t) syscall.Timespec { + return stat.Mtimespec +} diff --git a/archive/stat_linux.go b/archive/stat_linux.go new file mode 100644 index 0000000000..50b4627c4a --- /dev/null +++ b/archive/stat_linux.go @@ -0,0 +1,11 @@ +package archive + +import "syscall" + +func getLastAccess(stat *syscall.Stat_t) syscall.Timespec { + return stat.Atim +} + +func getLastModification(stat *syscall.Stat_t) syscall.Timespec { + return stat.Mtim +}