From 72392a2d726be9439508b0c6d714c6d5e6584971 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 25 Jun 2018 15:15:17 +0100 Subject: [PATCH] azureblob: list the container to see if it exists #2118 This means that SAS URLs which are tied to a single container will work. --- backend/azureblob/azureblob.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 05a2238b7..a6946724e 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -573,10 +573,19 @@ func (f *Fs) Mkdir(dir string) error { if f.containerOK { return nil } + // List the container to see if it exists + err := f.list("", false, 1, func(remote string, object *storage.Blob, isDirectory bool) error { + return nil + }) + if err == nil { + f.markContainerOK() + return nil + } + // now try to create the container options := storage.CreateContainerOptions{ Access: storage.ContainerAccessTypePrivate, } - err := f.pacer.Call(func() (bool, error) { + err = f.pacer.Call(func() (bool, error) { err := f.cc.Create(&options) if err != nil { if storageErr, ok := err.(storage.AzureStorageServiceError); ok {