From e0d735549449701ae71ad2a5684eb4935c1a0c09 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Mon, 22 Jan 2018 22:58:30 -0500 Subject: [PATCH] URLEncode the file path to allow non-ascii characters in the path --- src/duplicacy_b2storage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/duplicacy_b2storage.go b/src/duplicacy_b2storage.go index 3e001c7..801c279 100644 --- a/src/duplicacy_b2storage.go +++ b/src/duplicacy_b2storage.go @@ -6,6 +6,7 @@ package duplicacy import ( "strings" + "net/url" ) type B2Storage struct { @@ -210,7 +211,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) + filePath = url.PathEscape(filePath) readCloser, _, err := storage.clients[threadIndex].DownloadFile(filePath) if err != nil { return err @@ -224,7 +225,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) + filePath = url.PathEscape(filePath) return storage.clients[threadIndex].UploadFile(filePath, content, storage.UploadRateLimit/len(storage.clients)) }