mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
parent
c189337b6e
commit
95567c68bf
24
cmd/posix.go
24
cmd/posix.go
@ -73,22 +73,28 @@ func checkPathLength(pathName string) error {
|
||||
func isDirEmpty(dirname string) bool {
|
||||
f, err := os.Open(dirname)
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to access directory.")
|
||||
errorIf(func() error {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(), "Unable to access directory.")
|
||||
return false
|
||||
}
|
||||
defer f.Close()
|
||||
// List one entry.
|
||||
_, err = f.Readdirnames(1)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
// Returns true if we have reached EOF, directory is indeed empty.
|
||||
return true
|
||||
}
|
||||
errorIf(err, "Unable to list directory.")
|
||||
if err != io.EOF {
|
||||
errorIf(func() error {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(), "Unable to list directory.")
|
||||
return false
|
||||
}
|
||||
// Directory is not empty.
|
||||
return false
|
||||
// Returns true if we have reached EOF, directory is indeed empty.
|
||||
return true
|
||||
}
|
||||
|
||||
// Initialize a new storage disk.
|
||||
|
Loading…
x
Reference in New Issue
Block a user