in airavata_django_portal_sdk/user_storage/api.py [0:0]
def exists(request, data_product=None, data_product_uri=None):
"""
Return True if replica for data_product exists in user storage. One of
`data_product` or `data_product_uri` is required.
"""
if data_product is None:
data_product = _get_data_product(request, data_product_uri)
if remoteapi.is_remote_api_configured():
resp = remoteapi.call(
request,
"/data-products/",
params={'product-uri': data_product.productUri},
raise_for_status=False)
if resp.status_code == HTTPStatus.NOT_FOUND:
return False
resp.raise_for_status()
data = resp.json()
return data['downloadURL'] is not None
else:
storage_resource_id, path = _get_replica_resource_id_and_filepath(data_product)
backend = get_user_storage_provider(request,
owner_username=data_product.ownerName,
storage_resource_id=storage_resource_id)
return backend.is_file(path)