webdav: fix infinite loop on failed directory creation - fixes #2714
This commit is contained in:
parent
941ad6bc62
commit
3f572e6bf2
1 changed files with 12 additions and 7 deletions
|
@ -601,10 +601,9 @@ func (f *Fs) mkParentDir(dirPath string) error {
|
||||||
return f.mkdir(parent)
|
return f.mkdir(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mkdir makes the directory and parents using native paths
|
// low level mkdir, only makes the directory, doesn't attempt to create parents
|
||||||
func (f *Fs) mkdir(dirPath string) error {
|
func (f *Fs) _mkdir(dirPath string) error {
|
||||||
// defer log.Trace(dirPath, "")("")
|
// We assume the root is already created
|
||||||
// We assume the root is already ceated
|
|
||||||
if dirPath == "" {
|
if dirPath == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -617,20 +616,26 @@ func (f *Fs) mkdir(dirPath string) error {
|
||||||
Path: dirPath,
|
Path: dirPath,
|
||||||
NoResponse: true,
|
NoResponse: true,
|
||||||
}
|
}
|
||||||
err := f.pacer.Call(func() (bool, error) {
|
return f.pacer.Call(func() (bool, error) {
|
||||||
resp, err := f.srv.Call(&opts)
|
resp, err := f.srv.Call(&opts)
|
||||||
return shouldRetry(resp, err)
|
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 {
|
if apiErr, ok := err.(*api.Error); ok {
|
||||||
// already exists
|
// already exists
|
||||||
if apiErr.StatusCode == http.StatusMethodNotAllowed || apiErr.StatusCode == http.StatusNotAcceptable {
|
if apiErr.StatusCode == http.StatusMethodNotAllowed || apiErr.StatusCode == http.StatusNotAcceptable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// parent does not exists
|
// parent does not exist
|
||||||
if apiErr.StatusCode == http.StatusConflict {
|
if apiErr.StatusCode == http.StatusConflict {
|
||||||
err = f.mkParentDir(dirPath)
|
err = f.mkParentDir(dirPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = f.mkdir(dirPath)
|
err = f._mkdir(dirPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue