You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/05/14 16:01:07 UTC
[airavata-django-portal-sdk] branch mft-integration updated:
AIRAVATA-3420 Fix remote api mode of create_user_dir to return resource id,
path tuple
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch mft-integration
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git
The following commit(s) were added to refs/heads/mft-integration by this push:
new 8b9e926 AIRAVATA-3420 Fix remote api mode of create_user_dir to return resource id, path tuple
8b9e926 is described below
commit 8b9e926367ae4ab8ca727cfeea767bd8e58a0664
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri May 14 12:00:51 2021 -0400
AIRAVATA-3420 Fix remote api mode of create_user_dir to return resource id, path tuple
---
airavata_django_portal_sdk/user_storage/api.py | 32 +++++++++++++++-----------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index 9ad2a31..a959daf 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -616,23 +616,27 @@ def get_experiment_dir(request, project_name=None, experiment_name=None, path=No
def create_user_dir(request, path="", dir_names=(), create_unique=False, storage_resource_id=None):
"""
Creates a directory, and intermediate directories if given, at the given
- path in the user's storage. `dir_names` should be either a list or tuple
- of directories names to create at the given path. If `create_unique` is
- True and the given `dir_names` results in an already existing directory,
- the `dir_names` will be modified (for example, random suffix added) until
- it results in a name for a directory that doesn't exist and that
- directory will get created. If `create_unique` is False (the default)
- and the directory already exists, no directory will be created, but the
- directory resource information will be returned. Returns a tuple of the
- storage_resource_id and resource_path of the directory resource.
+ path in the user's storage. `dir_names` should be either a list or tuple of
+ directories names to create at the given path. If `create_unique` is True
+ and the given `dir_names` results in an already existing directory, the
+ `dir_names` will be modified (for example, random suffix added) until it
+ results in a name for a directory that doesn't exist and that directory will
+ get created. If `create_unique` is False (the default) and the directory
+ already exists, no directory will be created, but the directory resource
+ information will be returned. `dir_names` may also be modified to sanitize
+ them for file paths, for example, converting spaces to underscores. Returns
+ a tuple of the storage_resource_id and resource_path of the directory
+ resource.
"""
if _is_remote_api():
logger.debug(f"path={path}")
- _call_remote_api(request,
- "/user-storage/~/{path}",
- path_params={"path": path},
- method="post")
- return
+ resp = _call_remote_api(request,
+ "/user-storage/~/{path}",
+ path_params={"path": path},
+ method="post")
+ path = resp.json()['path']
+ # FIXME: should use the storage_resource_id returned from remote API call
+ return storage_resource_id, path
backend = get_user_storage_provider(request, storage_resource_id=storage_resource_id)
# For backwards compatibility, manufacture the dir_names array as needed
if len(dir_names) == 0: