From e5beb5533675ed776de502a45b2e940c5be0d718 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Sat, 20 Jan 2018 22:59:41 -0500 Subject: [PATCH] Replace spaces in file paths with %20 (for repository ids with spaces) --- src/duplicacy_b2client.go | 3 +-- src/duplicacy_b2storage.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/duplicacy_b2client.go b/src/duplicacy_b2client.go index ef3cf9d..04ca02a 100644 --- a/src/duplicacy_b2client.go +++ b/src/duplicacy_b2client.go @@ -153,7 +153,7 @@ func (client *B2Client) call(url string, method string, requestHeaders map[strin return response.Body, response.Header, response.ContentLength, nil } - LOG_DEBUG("BACKBLAZE_CALL", "URL request '%s' returned status code %d", url, response.StatusCode) + LOG_DEBUG("BACKBLAZE_CALL", "URL request '%s %s' returned status code %d", method, url, response.StatusCode) io.Copy(ioutil.Discard, response.Body) response.Body.Close() @@ -170,7 +170,6 @@ func (client *B2Client) call(url string, method string, requestHeaders map[strin continue } else if response.StatusCode == 404 { if http.MethodHead == method { - LOG_DEBUG("BACKBLAZE_CALL", "URL request '%s' returned status code %d", url, response.StatusCode) return nil, nil, 0, nil } } else if response.StatusCode == 416 { diff --git a/src/duplicacy_b2storage.go b/src/duplicacy_b2storage.go index 48b9042..3e001c7 100644 --- a/src/duplicacy_b2storage.go +++ b/src/duplicacy_b2storage.go @@ -210,6 +210,7 @@ func (storage *B2Storage) GetFileInfo(threadIndex int, filePath string) (exist b // DownloadFile reads the file at 'filePath' into the chunk. func (storage *B2Storage) DownloadFile(threadIndex int, filePath string, chunk *Chunk) (err error) { + filePath = strings.Replace(filePath, " ", "%20", -1) readCloser, _, err := storage.clients[threadIndex].DownloadFile(filePath) if err != nil { return err @@ -223,6 +224,7 @@ func (storage *B2Storage) DownloadFile(threadIndex int, filePath string, chunk * // UploadFile writes 'content' to the file at 'filePath'. func (storage *B2Storage) UploadFile(threadIndex int, filePath string, content []byte) (err error) { + filePath = strings.Replace(filePath, " ", "%20", -1) return storage.clients[threadIndex].UploadFile(filePath, content, storage.UploadRateLimit/len(storage.clients)) }