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 2020/09/17 13:43:54 UTC

[airavata-django-portal-sdk] 04/05: AIRAVATA-3346: AIRAVATA-3346 removing deprecated user_file_exists

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch AIRAVATA-3346-implement-remote-fs-abstraction-of-user-storage
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git

commit b5f8260cd10869486a29bfe555a3fab76385a212
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Sep 16 14:44:07 2020 -0400

    AIRAVATA-3346: AIRAVATA-3346 removing deprecated user_file_exists
---
 airavata_django_portal_sdk/user_storage.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage.py b/airavata_django_portal_sdk/user_storage.py
index 2a48bb8..9c1cf57 100644
--- a/airavata_django_portal_sdk/user_storage.py
+++ b/airavata_django_portal_sdk/user_storage.py
@@ -221,16 +221,6 @@ def dir_exists(request, path):
         return _Datastore().dir_exists(request.user.username, path)
 
 
-def user_file_exists(request, path):
-    """If file exists, return data product URI, else None."""
-    if _Datastore().exists(request.user.username, path):
-        full_path = _Datastore().path(request.user.username, path)
-        data_product_uri = _get_data_product_uri(request, full_path)
-        return data_product_uri
-    else:
-        return None
-
-
 def delete_dir(request, path):
     """Delete path in user's data store, if it exists."""
     if getattr(settings, 'GATEWAY_DATA_STORE_REMOTE_API', None) is not None:
@@ -249,6 +239,17 @@ def delete_dir(request, path):
 
 def delete_user_file(request, path):
     """Delete file in user's data store, if it exists."""
+    if getattr(settings, 'GATEWAY_DATA_STORE_REMOTE_API', None) is not None:
+        headers = {
+            'Authorization': f'Bearer {request.authz_token.accessToken}'}
+        r = requests.delete(
+            f'{settings.GATEWAY_DATA_STORE_REMOTE_API}/user-storage/~/{path}',
+            headers=headers,
+        )
+        if r.status_code == 404:
+            raise ObjectDoesNotExist(f"File path does not exist {path}")
+        r.raise_for_status()
+        return
     return _Datastore().delete(request.user.username, path)