mirror of https://github.com/minio/minio.git
pkg/fs: skip unnecessary os.Stat system call
This commit is contained in:
parent
0a0451a0fb
commit
7399d8ceaa
|
@ -36,14 +36,11 @@ func (fs Filesystem) DeleteBucket(bucket string) *probe.Error {
|
|||
}
|
||||
bucket = fs.denormalizeBucket(bucket)
|
||||
bucketDir := filepath.Join(fs.path, bucket)
|
||||
// Check if bucket exists.
|
||||
if _, e := os.Stat(bucketDir); e != nil {
|
||||
if e := os.Remove(bucketDir); e != nil {
|
||||
// Error if there was no bucket in the first place.
|
||||
if os.IsNotExist(e) {
|
||||
return probe.NewError(BucketNotFound{Bucket: bucket})
|
||||
}
|
||||
return probe.NewError(e)
|
||||
}
|
||||
if e := os.Remove(bucketDir); e != nil {
|
||||
// On windows the string is slightly different, handle it here.
|
||||
if strings.Contains(e.Error(), "directory is not empty") {
|
||||
return probe.NewError(BucketNotEmpty{Bucket: bucket})
|
||||
|
|
Loading…
Reference in New Issue