Skip to content

Commit 462dc83

Browse files
authored
Merge pull request #19930 from davelopez/24.1_fix_invenio_download_reliability
[24.1] Fix Invenio file source downloads not working with some Invenio instances
2 parents b731dde + 4f6c4a0 commit 462dc83

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/galaxy/files/sources/invenio.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,10 @@ def _get_download_file_url(self, record_id: str, filename: str, user_context: Op
347347
if is_draft_record:
348348
file_details_url = self._to_draft_url(file_details_url)
349349
download_file_content_url = self._to_draft_url(download_file_content_url)
350-
file_details = self._get_response(user_context, file_details_url)
351-
if not self._can_download_from_api(file_details):
352-
# TODO: This is a temporary workaround for the fact that the "content" API
353-
# does not support downloading files from S3 or other remote storage classes.
354-
# More info: https://inveniordm.docs.cern.ch/reference/file_storage/#remote-files-r
355-
download_file_content_url = f"{file_details_url.replace('/api', '')}?download=1"
350+
# Downloading through the API is only supported for local files and depends on how
351+
# the InvenioRDM instance file storage is configured.
352+
# So this is the most reliable way to download files for now it.
353+
download_file_content_url = f"{file_details_url.replace('/api', '')}?download=1"
356354
return download_file_content_url
357355

358356
def _is_api_url(self, url: str) -> bool:
@@ -361,11 +359,6 @@ def _is_api_url(self, url: str) -> bool:
361359
def _to_draft_url(self, url: str) -> str:
362360
return url.replace("/files/", "/draft/files/")
363361

364-
def _can_download_from_api(self, file_details: dict) -> bool:
365-
# Only files stored locally seems to be fully supported by the API for now
366-
# More info: https://inveniordm.docs.cern.ch/reference/file_storage/
367-
return file_details["storage_class"] == "L"
368-
369362
def _is_draft_record(self, record_id: str, user_context: OptionalUserContext = None):
370363
request_url = self._get_draft_record_url(record_id)
371364
headers = self._get_request_headers(user_context)

0 commit comments

Comments
 (0)