Fix ModTime for directories

This commit is contained in:
Florian Weingarten
2015-05-13 23:11:31 -04:00
parent 396a69886c
commit bace4607bf
3 changed files with 27 additions and 3 deletions

15
node.go Normal file → Executable file
View File

@@ -155,12 +155,23 @@ func (node Node) restoreMetadata(path string) error {
return errors.Annotate(err, "Chmod")
}
if node.Type != "dir" {
err = node.RestoreTimestamps(path)
if err != nil {
return err
}
}
return nil
}
func (node Node) RestoreTimestamps(path string) error {
var utimes = []syscall.Timespec{
syscall.NsecToTimespec(node.AccessTime.UnixNano()),
syscall.NsecToTimespec(node.ModTime.UnixNano()),
}
err = syscall.UtimesNano(path, utimes)
if err != nil {
if err := syscall.UtimesNano(path, utimes); err != nil {
return errors.Annotate(err, "UtimesNano")
}