1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-20 10:13:20 +00:00

Retry on "unexpected EOF" errors for the webdav backend.

This commit is contained in:
Gilbert Chen
2020-07-03 11:48:30 -04:00
parent 153f6a2d20
commit f2f07a120d

View File

@@ -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
} }
@@ -261,6 +262,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