From 76c5aa85336051ded84983f9ef807390386a8d51 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 10 Aug 2017 10:29:21 +0100 Subject: [PATCH] gcs: Check for errors when testing bucket is OK in mkdir #1590 Previously we would check the bucket's status and on error we would try to create it. Now we only try to create it if we got a not found error, otherwise we report the error to the user. --- googlecloudstorage/googlecloudstorage.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go index 40ceaf670..8285dcf9d 100644 --- a/googlecloudstorage/googlecloudstorage.go +++ b/googlecloudstorage/googlecloudstorage.go @@ -578,6 +578,12 @@ func (f *Fs) Mkdir(dir string) error { // Bucket already exists f.bucketOK = true return nil + } else if gErr, ok := err.(*googleapi.Error); ok { + if gErr.Code != http.StatusNotFound { + return errors.Wrap(err, "failed to get bucket") + } + } else { + return errors.Wrap(err, "failed to get bucket") } if f.projectNumber == "" {