Browse Source

Merge pull request #34 from orijtech/develop

common/IsDirEmpty: do not mask non-existance errors
pull/1842/head
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
fe08fc00c8
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      common/os.go

+ 6
- 1
common/os.go View File

@ -48,7 +48,12 @@ func EnsureDir(dir string, mode os.FileMode) error {
func IsDirEmpty(name string) (bool, error) { func IsDirEmpty(name string) (bool, error) {
f, err := os.Open(name) f, err := os.Open(name)
if err != nil { 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() defer f.Close()


Loading…
Cancel
Save