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

Compare commits

...

3 Commits

Author SHA1 Message Date
Luca Trevisani
92cb29293c Merge 74bb98a58c into 065ae50868 2025-02-02 15:04:53 +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
Luca Trevisani
74bb98a58c Fix -zstd flag documentation 2023-11-09 23:20:21 +01:00
2 changed files with 15 additions and 10 deletions

View File

@@ -1456,7 +1456,7 @@ func main() {
},
cli.BoolFlag{
Name: "zstd",
Usage: "short for -zstd default",
Usage: "short for -zstd-level default",
},
cli.IntFlag{
Name: "iterations",
@@ -1532,7 +1532,7 @@ func main() {
},
cli.BoolFlag{
Name: "zstd",
Usage: "short for -zstd default",
Usage: "short for -zstd-level default",
},
cli.BoolFlag{
Name: "vss",
@@ -1984,7 +1984,7 @@ func main() {
},
cli.BoolFlag{
Name: "zstd",
Usage: "short for -zstd default",
Usage: "short for -zstd-level default",
},
cli.IntFlag{
Name: "iterations",

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"]