This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/develop by this push:
new b6dfed3 AIRAVATA-3460 Handle created directory with different name
than requested
b6dfed3 is described below
commit b6dfed37c562e5defe841ddbf6bc3ed231adfa28
Author: Marcus Christie <[email protected]>
AuthorDate: Fri May 14 12:04:05 2021 -0400
AIRAVATA-3460 Handle created directory with different name than requested
---
django_airavata/apps/api/serializers.py | 1 +
django_airavata/apps/api/views.py | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/django_airavata/apps/api/serializers.py
b/django_airavata/apps/api/serializers.py
index e355b63..ec68e11 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -884,6 +884,7 @@ class UserStoragePathSerializer(serializers.Serializer):
directories = UserStorageDirectorySerializer(many=True)
files = UserStorageFileSerializer(many=True)
parts = serializers.ListField(child=serializers.CharField())
+ path = serializers.CharField()
# uploaded is populated after a file upload
uploaded = DataProductSerializer(read_only=True)
diff --git a/django_airavata/apps/api/views.py
b/django_airavata/apps/api/views.py
index 1519cfc..91c69da 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -1539,7 +1539,11 @@ class UserStoragePathView(APIView):
def post(self, request, path="/", format=None):
if not user_storage.dir_exists(request, path):
- user_storage.create_user_dir(request, path)
+ _, resource_path = user_storage.create_user_dir(request, path)
+ # create_user_dir may create the directory with a different name
+ # than requested, for example, converting spaces to underscores, so
+ # use as the path the path that is returned by create_user_dir
+ path = resource_path
data_product = None
# Handle direct upload
@@ -1595,6 +1599,7 @@ class UserStoragePathView(APIView):
if uploaded is not None:
data['uploaded'] = uploaded
data['parts'] = self._split_path(path)
+ data['path'] = path
serializer = self.serializer_class(
data, context={'request': request})
return Response(serializer.data)
@@ -1614,7 +1619,7 @@ class UserStoragePathView(APIView):
def _split_path(self, path):
head, tail = os.path.split(path)
- if head != "":
+ if head != path:
return self._split_path(head) + [tail]
elif tail != "":
return [tail]