From 7399d8ceaa1659d853ea0db711e5c2f5314f7fbc Mon Sep 17 00:00:00 2001 From: Brendan Ashworth Date: Sun, 6 Mar 2016 23:54:43 -0800 Subject: [PATCH] pkg/fs: skip unnecessary os.Stat system call --- pkg/fs/fs-bucket.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/fs/fs-bucket.go b/pkg/fs/fs-bucket.go index e7ff8d358..1a598e82a 100644 --- a/pkg/fs/fs-bucket.go +++ b/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})