mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-20 18:23:29 +00:00
Retry on "unexpected EOF" errors for the webdav backend.
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
//"net/http/httputil"
|
//"net/http/httputil"
|
||||||
@@ -214,6 +213,8 @@ type WebDAVMultiStatus struct {
|
|||||||
|
|
||||||
func (storage *WebDAVStorage) getProperties(uri string, depth int, properties ...string) (map[string]WebDAVProperties, error) {
|
func (storage *WebDAVStorage) getProperties(uri string, depth int, properties ...string) (map[string]WebDAVProperties, error) {
|
||||||
|
|
||||||
|
maxTries := 3
|
||||||
|
for tries := 0; ; tries++ {
|
||||||
propfind := "<prop>"
|
propfind := "<prop>"
|
||||||
for _, p := range properties {
|
for _, p := range properties {
|
||||||
propfind += fmt.Sprintf("<%s/>", p)
|
propfind += fmt.Sprintf("<%s/>", p)
|
||||||
@@ -227,14 +228,14 @@ func (storage *WebDAVStorage) getProperties(uri string, depth int, properties ..
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer readCloser.Close()
|
defer readCloser.Close()
|
||||||
content, err := ioutil.ReadAll(readCloser)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
object := WebDAVMultiStatus{}
|
object := WebDAVMultiStatus{}
|
||||||
err = xml.Unmarshal(content, &object)
|
err = xml.NewDecoder(readCloser).Decode(&object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if strings.Contains(err.Error(), "unexpected EOF") && tries < maxTries {
|
||||||
|
LOG_WARN("WEBDAV_RETRY", "Retrying on %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +263,7 @@ func (storage *WebDAVStorage) getProperties(uri string, depth int, properties ..
|
|||||||
|
|
||||||
return responses, nil
|
return responses, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ListFiles return the list of files and subdirectories under 'dir'. A subdirectories returned must have a trailing '/', with
|
// ListFiles return the list of files and subdirectories under 'dir'. A subdirectories returned must have a trailing '/', with
|
||||||
// a size of 0. If 'dir' is 'snapshots', only subdirectories will be returned. If 'dir' is 'snapshots/repository_id', then only
|
// a size of 0. If 'dir' is 'snapshots', only subdirectories will be returned. If 'dir' is 'snapshots/repository_id', then only
|
||||||
|
|||||||
Reference in New Issue
Block a user