From e251b8616e3679e11c17ab1e28712dede800e567 Mon Sep 17 00:00:00 2001 From: gutmet Date: Wed, 20 Feb 2019 00:27:51 +0100 Subject: [PATCH] set mod time after copy --- copy.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/copy.go b/copy.go index b529dca..2e6bf3d 100644 --- a/copy.go +++ b/copy.go @@ -32,6 +32,7 @@ import ( "io/ioutil" "os" "path/filepath" + "time" ) // Copy copies src to dest, doesn't matter if src is a directory or a file @@ -65,15 +66,15 @@ func filecopy(src, dest string, info os.FileInfo) error { if err = os.Chmod(f.Name(), info.Mode()); err != nil { return err } - if err = os.Chtimes(f.Name(), info.ModTime(), info.ModTime()); err != nil { - return err - } s, err := os.Open(src) if err != nil { return err } defer s.Close() _, err = io.Copy(f, s) + if err = os.Chtimes(f.Name(), time.Now().Local(), info.ModTime()); err != nil { + return err + } return err }