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

webdav: fix infinite loop on failed directory creation - fixes #2714

Nick Craig-Wood3f572e6bf294
diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go
index 8370d7904..2738d6200 100644
--- a/backend/webdav/webdav.go
+++ b/backend/webdav/webdav.go
@@ -601,10 +601,9 @@ func (f *Fs) mkParentDir(dirPath string) error {
return f.mkdir(parent)
}
-// mkdir makes the directory and parents using native paths
-func (f *Fs) mkdir(dirPath string) error {
- // defer log.Trace(dirPath, "")("")
- // We assume the root is already ceated
+// low level mkdir, only makes the directory, doesn't attempt to create parents
+func (f *Fs) _mkdir(dirPath string) error {
+ // We assume the root is already created
if dirPath == "" {
return nil
}
@@ -617,20 +616,26 @@ func (f *Fs) mkdir(dirPath string) error {
Path: dirPath,
NoResponse: true,
}
- err := f.pacer.Call(func() (bool, error) {
+ return f.pacer.Call(func() (bool, error) {
resp, err := f.srv.Call(&opts)
return shouldRetry(resp, err)
})
+}
+
+// mkdir makes the directory and parents using native paths
+func (f *Fs) mkdir(dirPath string) error {
+ // defer log.Trace(dirPath, "")("")
+ err := f._mkdir(dirPath)
if apiErr, ok := err.(*api.Error); ok {
// already exists
if apiErr.StatusCode == http.StatusMethodNotAllowed || apiErr.StatusCode == http.StatusNotAcceptable {
return nil
}
- // parent does not exists
+ // parent does not exist
if apiErr.StatusCode == http.StatusConflict {
err = f.mkParentDir(dirPath)
if err == nil {
- err = f.mkdir(dirPath)
+ err = f._mkdir(dirPath)
}
}
}