Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

swift: Fix upload from unprivileged user - fixes #273

Nick Craig-Woodc3a0c0c45198
diff --git a/swift/swift.go b/swift/swift.go
index 1241b70db..3c6dbbaf3 100644
--- a/swift/swift.go
+++ b/swift/swift.go
@@ -382,7 +382,16 @@ func (f *Fs) Put(in io.Reader, remote string, modTime time.Time, size int64) (fs
// Mkdir creates the container if it doesn't exist
func (f *Fs) Mkdir() error {
- return f.c.ContainerCreate(f.container, nil)
+ // Check to see if container exists first
+ _, _, err := f.c.Container(f.container)
+ if err == nil {
+ return nil
+ }
+ if err == swift.ContainerNotFound {
+ return f.c.ContainerCreate(f.container, nil)
+ }
+ return err
+
}
// Rmdir deletes the container if the fs is at the root