Don't copy unmodified files from source to dest
This commit is contained in:
parent
da057ec544
commit
31beb8b2c0
4
file.go
4
file.go
@ -39,6 +39,10 @@ type file struct {
|
||||
}
|
||||
|
||||
func (f *file) export(dstPath string) error {
|
||||
if f.reader == nil && fileCached(f.asset, dstPath) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(path.Dir(dstPath), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
14
util.go
14
util.go
@ -66,3 +66,17 @@ func scanDir(root string, files, dirs chan string) {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func fileCached(srcPath, dstPath string) bool {
|
||||
srcStat, err := os.Stat(srcPath)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dstStat, err := os.Stat(dstPath)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return dstStat.ModTime().Unix() >= srcStat.ModTime().Unix()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user