1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-06 00:03:38 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
sevimo123
37001d622f Merge 4056618204 into 065ae50868 2025-02-02 15:04:26 +00:00
Gilbert Chen
065ae50868 Improve parsing logic for swift storage URLs that contain multiple '@'
Parse the storage URL first, then use a regex to ensure the server name is
correctly identified starting after the final '@'.
2024-12-19 08:54:22 -05:00
Victor Mozgin
4056618204 Fixed 400 error processing for MoveFile/PATCH (in this case there are valid 400 errors that designate non-existent target directory) 2023-04-14 19:32:58 -04:00
Victor Mozgin
ee344a0abe OneDrive sometimes generates spurious 400 errors, these are perfectly fine to retry on instead of failing the whole run. 2023-03-06 11:02:42 -05:00
2 changed files with 18 additions and 8 deletions

View File

@@ -201,7 +201,12 @@ func (client *OneDriveClient) call(url string, method string, input interface{},
continue
} else if response.StatusCode == 409 {
return nil, 0, OneDriveError{Status: response.StatusCode, Message: "Conflict"}
} else if response.StatusCode > 401 && response.StatusCode != 404 {
} else if response.StatusCode >= 400 && response.StatusCode != 404 && !(
method == "PATCH" && response.StatusCode == 400) {
// MoveFile uses PATCH method, and it unfortunately relies on
// processing 400 errors for detecting non-existent target
// folders. So in this case we bubble up 400 errors to be handled
// in MoveFile
delay := int((rand.Float32() * 0.5 + 0.5) * 1000.0 * float32(backoff))
if backoffList, found := response.Header["Retry-After"]; found && len(backoffList) > 0 {
retryAfter, _ := strconv.Atoi(backoffList[0])

View File

@@ -9,6 +9,7 @@ import (
"strconv"
"strings"
"time"
"regexp"
"github.com/ncw/swift/v2"
)
@@ -42,13 +43,6 @@ func CreateSwiftStorage(storageURL string, key string, threads int) (storage *Sw
}
}
// Take out the user name if there is one
if strings.Contains(storageURL, "@") {
userAndURL := strings.Split(storageURL, "@")
arguments["user"] = userAndURL[0]
storageURL = userAndURL[1]
}
// The version is used to split authURL and container/path
versions := []string{"/v1/", "/v1.0/", "/v2/", "/v2.0/", "/v3/", "/v3.0/", "/v4/", "/v4.0/"}
storageDir := ""
@@ -60,6 +54,17 @@ func CreateSwiftStorage(storageURL string, key string, threads int) (storage *Sw
}
}
// Take out the user name if there is one
if strings.Contains(storageURL, "@") {
// Use regex to split the username and the rest of the URL
lineRegex := regexp.MustCompile(`^(.+)@([^@]+)$`)
match := lineRegex.FindStringSubmatch(storageURL)
if match != nil {
arguments["user"] = match[1]
storageURL = match[2]
}
}
// If no container/path is specified, find them from the arguments
if storageDir == "" {
storageDir = arguments["storage_dir"]