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/10/05 14:38:57 UTC

[airavata-django-portal-sdk] branch master updated: Quote file path in replica location URI

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

machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ef7fbb  Quote file path in replica location URI
0ef7fbb is described below

commit 0ef7fbb616bff5fe0bb2d857034570b8f45c1568
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Mon Oct 5 10:38:36 2020 -0400

    Quote file path in replica location URI
---
 airavata_django_portal_sdk/user_storage.py | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage.py b/airavata_django_portal_sdk/user_storage.py
index 9983e8d..2baaadc 100644
--- a/airavata_django_portal_sdk/user_storage.py
+++ b/airavata_django_portal_sdk/user_storage.py
@@ -1,11 +1,18 @@
+import cgi
 import copy
+import io
 import logging
 import mimetypes
 import os
 import shutil
-from urllib.parse import quote, urlparse
+from urllib.parse import quote, unquote, urlparse
 
 import requests
+from airavata.model.data.replica.ttypes import (DataProductModel,
+                                                DataProductType,
+                                                DataReplicaLocationModel,
+                                                ReplicaLocationCategory,
+                                                ReplicaPersistentType)
 from django.apps import apps
 from django.conf import settings
 from django.core.exceptions import ObjectDoesNotExist, SuspiciousFileOperation
@@ -13,15 +20,7 @@ from django.core.files import File
 from django.core.files.move import file_move_safe
 from django.core.files.storage import FileSystemStorage
 
-from airavata.model.data.replica.ttypes import (DataProductModel,
-                                                DataProductType,
-                                                DataReplicaLocationModel,
-                                                ReplicaLocationCategory,
-                                                ReplicaPersistentType)
-
 from .util import convert_iso8601_to_datetime
-import io
-import cgi
 
 logger = logging.getLogger(__name__)
 
@@ -520,7 +519,7 @@ def _create_replica_location(full_path, file_name):
     )
     data_replica_location.replicaPersistentType = ReplicaPersistentType.TRANSIENT
     data_replica_location.filePath = "file://{}:{}".format(
-        settings.GATEWAY_DATA_STORE_HOSTNAME, full_path
+        settings.GATEWAY_DATA_STORE_HOSTNAME, quote(full_path)
     )
     return data_replica_location
 
@@ -534,7 +533,7 @@ def _get_replica_filepath(data_product):
     replica_filepath = replica_filepaths[0] if len(
         replica_filepaths) > 0 else None
     if replica_filepath:
-        return urlparse(replica_filepath).path
+        return unquote(urlparse(replica_filepath).path)
     return None