Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cterasdk/cio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def makedir(path):
@contextmanager
def rename(path, name):
param = ActionResourcesParam.instance()
param.add(SrcDstParam.instance(src=path.absolute, dest=path.parent.join(name).absolute))
param.add(SrcDstParam.instance(src=path.absolute_encode, dest=path.parent.join(name).absolute_encode))
logger.info('Renaming item: %s to: %s', path.reference.as_posix(), name)
yield param

Expand All @@ -219,7 +219,7 @@ def _delete_or_recover(paths, *, message=None):
param = ActionResourcesParam.instance()
paths = [paths] if not isinstance(paths, list) else paths
for path in paths:
param.add(SrcDstParam.instance(src=path.absolute))
param.add(SrcDstParam.instance(src=path.absolute_encode))
if message:
logger.info('%s: %s', message, path.reference.as_posix())
yield param
Expand All @@ -239,7 +239,7 @@ def _copy_or_move(paths, destination, *, message=None):
param = ActionResourcesParam.instance()
paths = [paths] if not isinstance(paths, list) else paths
for path in paths:
param.add(SrcDstParam.instance(src=path.absolute, dest=destination.join(path.name).absolute))
param.add(SrcDstParam.instance(src=path.absolute_encode, dest=destination.join(path.name).absolute_encode))
if message:
logger.info('%s from: %s to: %s', message, path.reference.as_posix(), destination.join(path.name).reference.as_posix())
yield param
Expand All @@ -260,7 +260,7 @@ def public_link(path, access, expire_in):
access = {'RO': 'ReadOnly', 'RW': 'ReadWrite', 'PO': 'PreviewOnly'}.get(access)
expire_on = DateTimeUtils.get_expiration_date(expire_in).strftime('%Y-%m-%d')
logger.info('Creating Public Link for: %s. Access: %s. Expires: %s', path.reference.as_posix(), access, expire_on)
param = CreateShareParam.instance(path=path.absolute, access=access, expire_on=expire_on)
param = CreateShareParam.instance(path=path.absolute_encode, access=access, expire_on=expire_on)
yield param


Expand Down Expand Up @@ -320,7 +320,7 @@ def share(path, as_project, allow_reshare, allow_sync, shares=None):

param = Object()
param._classname = 'ShareResourceParam' # pylint: disable=protected-access
param.url = path.absolute
param.url = path.absolute_encode
param.teamProject = as_project
param.allowReshare = allow_reshare
param.shouldSync = allow_sync
Expand Down
10 changes: 10 additions & 0 deletions docs/source/UserGuides/Miscellaneous/Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

2.20.14
-------

Bug Fixes
^^^^^^^^^

* CTERA Portal: Added support for special characters when copying, moving, renaming, sharing, and deleting files.

Related issues and pull requests on GitHub: `#304 <https://github.com/ctera/ctera-python-sdk/pull/304>`_

2.20.13
-------

Expand Down
5 changes: 5 additions & 0 deletions tests/ut/core/user/base_user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import mock
from urllib.parse import quote

from cterasdk.common import Object
from cterasdk.objects import ServicesPortal
Expand All @@ -12,6 +13,10 @@ def setUp(self):
self._services = ServicesPortal("")
self._base = '/ServicesPortal/webdav'

@staticmethod
def encode_path(path):
return quote(path)

def _init_services(self, execute_response=None, form_data_response=None):
self._services.api.execute = mock.MagicMock(return_value=execute_response)
self._services.api.form_data = mock.MagicMock(return_value=form_data_response)
Expand Down
4 changes: 2 additions & 2 deletions tests/ut/core/user/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def test_copy(self):
self.assertEqual(ret, execute_response)

def _create_copy_resource_param(self):
destinations = [self._dest + '/' + self._filename]
return self._create_action_resource_param([self._source], destinations)
destinations = [base_user.BaseCoreServicesTest.encode_path(self._dest + '/' + self._filename)]
return self._create_action_resource_param([base_user.BaseCoreServicesTest.encode_path(self._source)], destinations)
2 changes: 1 addition & 1 deletion tests/ut/core/user/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def test_delete(self):
self.assertEqual(ret, execute_response)

def _create_delete_resource_param(self):
return self._create_action_resource_param([self._path])
return self._create_action_resource_param([base_user.BaseCoreServicesTest.encode_path(self._path)])
4 changes: 2 additions & 2 deletions tests/ut/core/user/test_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def test_move(self):
self.assertEqual(ret, execute_response)

def _create_move_resource_param(self):
destinations = [self._dest + '/' + self._filename]
return self._create_action_resource_param([self._source], destinations)
destinations = [base_user.BaseCoreServicesTest.encode_path(self._dest + '/' + self._filename)]
return self._create_action_resource_param([base_user.BaseCoreServicesTest.encode_path(self._source)], destinations)
2 changes: 1 addition & 1 deletion tests/ut/core/user/test_public_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _create_public_link_response(self):
def _create_public_link_param(self, access_mode, expire_in):
param = Object()
param._classname = 'CreateShareParam' # pylint: disable=protected-access
param.url = f'{self._base}/{self._path}'
param.url = base_user.BaseCoreServicesTest.encode_path(f'{self._base}/{self._path}')
param.share = Object()
param.share._classname = 'ShareConfig' # pylint: disable=protected-access
param.share.accessMode = access_mode
Expand Down
4 changes: 2 additions & 2 deletions tests/ut/core/user/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def test_rename(self):
self.assertEqual(ret, execute_response)

def _create_rename_resource_param(self):
sources = [self._parent_directory + '/' + self._current_filename]
destinations = [self._parent_directory + '/' + self._new_filename]
sources = [base_user.BaseCoreServicesTest.encode_path(self._parent_directory + '/' + self._current_filename)]
destinations = [base_user.BaseCoreServicesTest.encode_path(self._parent_directory + '/' + self._new_filename)]
return self._create_action_resource_param(sources, destinations)
2 changes: 1 addition & 1 deletion tests/ut/core/user/test_undelete.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def test_undelete(self):
self.assertEqual(ret, execute_response)

def _create_undelete_resource_param(self):
return self._create_action_resource_param([self._path])
return self._create_action_resource_param([base_user.BaseCoreServicesTest.encode_path(self._path)])