set mod time after copy
This commit is contained in:
parent
ab2b1e8f6a
commit
e251b8616e
7
copy.go
7
copy.go
|
@ -32,6 +32,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Copy copies src to dest, doesn't matter if src is a directory or a file
|
// 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 {
|
if err = os.Chmod(f.Name(), info.Mode()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = os.Chtimes(f.Name(), info.ModTime(), info.ModTime()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s, err := os.Open(src)
|
s, err := os.Open(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
_, err = io.Copy(f, s)
|
_, err = io.Copy(f, s)
|
||||||
|
if err = os.Chtimes(f.Name(), time.Now().Local(), info.ModTime()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user