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

Make Wasabi double slash fix more idiomatic

This commit is contained in:
Jason Tackaberry
2018-07-13 12:43:27 -04:00
parent 84f7c513d5
commit 117cfd997f

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"net/http"
"time"
"strings"
)
type WasabiStorage struct {
@@ -98,10 +97,14 @@ func (storage *WasabiStorage) MoveFile(
threadIndex int, from string, to string,
) (err error) {
// The from path includes the bucket
from_path := fmt.Sprintf("/%s/%s/%s", storage.bucket, storage.storageDir, from)
// Ensure no double slashes exist in the path which angers Wasabi's backend
from_path = strings.Replace(from_path, "//", "/", -1)
var from_path string
// The from path includes the bucket. Take care not to include an empty storageDir
// string as Wasabi's backend will return 404 on URLs with double slashes.
if (storage.storageDir == "") {
from_path = fmt.Sprintf("/%s/%s", storage.bucket, from)
} else {
from_path = fmt.Sprintf("/%s/%s/%s", storage.bucket, storage.storageDir, from)
}
object := fmt.Sprintf("https://%s@%s%s",
storage.region, storage.endpoint, from_path)