diff --git a/file.go b/file.go index 719fd28..60c024b 100644 --- a/file.go +++ b/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 } diff --git a/util.go b/util.go index 12cbd58..18a032d 100644 --- a/util.go +++ b/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() +}