diff --git a/shutil.go b/shutil.go index 8ebc437..09fcd38 100644 --- a/shutil.go +++ b/shutil.go @@ -263,7 +263,6 @@ func CopyTree(src, dst string, options *CopyTreeOptions) error { return &AlreadyExistsError{dst} } - entries, err := ioutil.ReadDir(src) if err != nil { return err @@ -279,7 +278,6 @@ func CopyTree(src, dst string, options *CopyTreeOptions) error { ignoredNames = options.Ignore(src, entries) } - for _, entry := range entries { if stringInSlice(entry.Name(), ignoredNames) { continue @@ -313,7 +311,10 @@ func CopyTree(src, dst string, options *CopyTreeOptions) error { } } } else if entryFileInfo.IsDir() { - return CopyTree(srcPath, dstPath, options) + err = CopyTree(srcPath, dstPath, options) + if err != nil { + return err + } } else { _, err = options.CopyFunction(srcPath, dstPath, false) if err != nil {