pkg/fs: skip unnecessary os.Stat system call

master
Brendan Ashworth 9 years ago
parent 0a0451a0fb
commit 7399d8ceaa
  1. 7
      pkg/fs/fs-bucket.go

@ -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…
Cancel
Save