diff --git a/file.go b/file.go index 3432ddf..6e12532 100644 --- a/file.go +++ b/file.go @@ -45,8 +45,11 @@ type file struct { func (f *file) export(dstDir string) error { dstPath := filepath.Join(dstDir, f.path) - if len(f.asset) > 0 && fileCached(f.asset, dstPath) { - return nil + if len(f.asset) > 0 { + dstInfo, err := os.Stat(dstPath) + if err == nil && dstInfo.ModTime().Unix() >= f.ModTime().Unix() { + return nil + } } if err := os.MkdirAll(path.Dir(dstPath), 0755); err != nil { diff --git a/goldsmith.go b/goldsmith.go index cce2b5e..fa32316 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -24,6 +24,7 @@ package goldsmith import ( "bytes" + "errors" "io" "os" "time" @@ -73,6 +74,10 @@ func NewFileFromAsset(path, asset string) (File, error) { return nil, err } + if info.IsDir() { + return nil, errors.New("assets must be files") + } + f := &file{ path: path, Meta: make(map[string]interface{}), diff --git a/util.go b/util.go index 6897388..f5d0164 100644 --- a/util.go +++ b/util.go @@ -55,17 +55,3 @@ func scanDir(root string, infos chan fileInfo) { 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() -}