Skip to content

Commit

Permalink
Added small changes to handle path encoding in some client and dccplu…
Browse files Browse the repository at this point in the history
…gin functions
  • Loading branch information
tpoveda committed May 27, 2021
1 parent b024524 commit d1ea27b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion artella/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ def status(self, file_paths, include_remote=False):
file_path = file_path.decode('latin-1')
uri_path = path_to_uri(file_path) if not is_uri_path(file_path) else file_path
uri_parts = urlparse(uri_path)
params = urlencode({'handle': uri_parts.path, 'include-remote': str(bool(include_remote)).lower()})
uri_handle = utils.clean_path(uri_parts.path)
params = urlencode({'handle': uri_handle, 'include-remote': str(bool(include_remote)).lower()})
req = Request('http://{}:{}/v2/localserve/fileinfo?{}'.format(
self._host, self._port, params))
rsp = self._communicate(req)
Expand Down
2 changes: 2 additions & 0 deletions artella/core/dccplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ def make_new_version(self, file_path=None, comment=None, do_lock=False):
logger.warning(msg)
return False

file_path = utils.clean_path(file_path)

can_lock = artella_drive_client.can_lock_file(file_path=file_path)
if not can_lock:
msg = 'Unable to lock file to make new version. File is already locked by other user.'
Expand Down
5 changes: 3 additions & 2 deletions artella/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import importlib
import subprocess
from functools import wraps

try:
from importlib.machinery import SourceFileLoader
except ImportError:
Expand Down Expand Up @@ -91,9 +92,9 @@ def clean_path(path):
path = os.path.expanduser(path)
else:
try:
path = os.path.expanduser(str(path.encode('latin1')))
except Exception:
path = os.path.expanduser(str(path.encode('utf-8')))
except Exception:
path = os.path.expanduser(str(path.encode('latin1')))
path = str(path.replace('\\', '/').replace('//', '/').rstrip('/').strip())

# Fix server paths
Expand Down

0 comments on commit d1ea27b

Please sign in to comment.