Merge pull request #34 from orijtech/develop

common/IsDirEmpty: do not mask non-existance errors
This commit is contained in:
Ethan Buchman
2017-08-25 16:01:30 -04:00
committed by GitHub

View File

@@ -48,7 +48,12 @@ func EnsureDir(dir string, mode os.FileMode) error {
func IsDirEmpty(name string) (bool, error) {
f, err := os.Open(name)
if err != nil {
return true, err //folder is non-existent
if os.IsNotExist(err) {
return true, err
}
// Otherwise perhaps a permission
// error or some other error.
return false, err
}
defer f.Close()