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/04/29 21:56:29 UTC

[airavata-django-portal-sdk] branch mft-integration updated: AIRAVATA-3420 Handle special case of creating user's home directory

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 21119c5  AIRAVATA-3420 Handle special case of creating user's home directory
21119c5 is described below

commit 21119c5d78e53afb05996a78304be15edc003c13
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu Apr 29 17:56:12 2021 -0400

    AIRAVATA-3420 Handle special case of creating user's home directory
---
 airavata_django_portal_sdk/user_storage/api.py                        | 2 +-
 .../user_storage/backends/django_filesystem_provider.py               | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index 76761d4..87289f4 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -594,7 +594,7 @@ def create_user_dir(request, path="", dir_names=(), create_unique=False, storage
         while not backend.exists(path):
             path, dir_name = os.path.split(path)
             if dir_name == '':
-                raise Exception("Could not find a base directory in which to create directories.")
+                break
             dir_names.insert(0, dir_name)
     storage_resource_id, resource_path = backend.create_dirs(path, dir_names=dir_names, create_unique=create_unique)
     return storage_resource_id, resource_path
diff --git a/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py b/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py
index 98a0038..16845ca 100644
--- a/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py
+++ b/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py
@@ -104,6 +104,10 @@ class DjangoFileSystemProvider(UserStorageProvider):
 
     def create_dirs(self, resource_path, dir_names=[], create_unique=False):
         datastore = self.datastore
+        # Special case: handle creating user's home directory
+        if resource_path == '' and not datastore.exists(''):
+            datastore.create_user_dir('')
+            return self.storage_resource_id, ''
         if not datastore.exists(resource_path):
             raise ObjectDoesNotExist(f"User resource_path does not exist {resource_path}")
         valid_dir_names = []