Skip to content

Commit 4aa6204

Browse files
committed
fix(#61): quote file path when interacting with files
1 parent b402a33 commit 4aa6204

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

gogdl/saves.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import logging
44
import requests
5+
import urllib.parse
56
import hashlib
67
import datetime
78
import gzip
@@ -250,8 +251,9 @@ def get_auth_ids(self):
250251

251252
def delete_file(self, file: SyncFile):
252253
self.logger.info(f"Deleting {file.relative_path}")
254+
fpath = urllib.parse.quote(file.relative_path)
253255
response = self.session.delete(
254-
f"{constants.GOG_CLOUDSTORAGE}/v1/{self.credentials['user_id']}/{self.client_id}/{self.cloud_save_dir_name}/{file.relative_path}",
256+
f"{constants.GOG_CLOUDSTORAGE}/v1/{self.credentials['user_id']}/{self.client_id}/{self.cloud_save_dir_name}/{fpath}",
255257
)
256258

257259
def upload_file(self, file: SyncFile):
@@ -264,8 +266,9 @@ def upload_file(self, file: SyncFile):
264266
"Content-Encoding": "gzip",
265267
}
266268

269+
fpath = urllib.parse.quote(file.relative_path)
267270
response = self.session.put(
268-
f"{constants.GOG_CLOUDSTORAGE}/v1/{self.credentials['user_id']}/{self.client_id}/{self.cloud_save_dir_name}/{file.relative_path}",
271+
f"{constants.GOG_CLOUDSTORAGE}/v1/{self.credentials['user_id']}/{self.client_id}/{self.cloud_save_dir_name}/{fpath}",
269272
data=compressed_data,
270273
headers=headers,
271274
)
@@ -278,8 +281,9 @@ def upload_file(self, file: SyncFile):
278281

279282
def download_file(self, file: SyncFile, retries=3):
280283
try:
284+
fpath = urllib.parse.quote(file.relative_path)
281285
response = self.session.get(
282-
f"{constants.GOG_CLOUDSTORAGE}/v1/{self.credentials['user_id']}/{self.client_id}/{self.cloud_save_dir_name}/{file.relative_path}",
286+
f"{constants.GOG_CLOUDSTORAGE}/v1/{self.credentials['user_id']}/{self.client_id}/{self.cloud_save_dir_name}/{fpath}",
283287
stream=True,
284288
)
285289
except:

0 commit comments

Comments
 (0)