Skip to content

Commit

Permalink
Raise exception if collection elements missing during download
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed May 3, 2024
1 parent 7408ebb commit b0bbfde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/galaxy/managers/hdcas.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def stream_dataset_collection(dataset_collection_instance, upstream_mod_zip=Fals
def write_dataset_collection(dataset_collection_instance, archive):
names, hdas = get_hda_and_element_identifiers(dataset_collection_instance)
for name, hda in zip(names, hdas):
if not hda:
# TODO should we raise galaxy.exceptions.InternalServerError or create a new exception type?
raise Exception("Attempt to write dataset collection with missing elements")
if hda.state != hda.states.OK:
continue
for file_path, relpath in hda.datatype.to_archive(dataset=hda, name=name):
Expand Down
10 changes: 6 additions & 4 deletions lib/galaxy/webapps/galaxy/api/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,7 @@ def download_dataset_collection_history_content(
"""Download the content of a history dataset collection as a `zip` archive
while maintaining approximate collection structure.
"""
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
return StreamingResponse(archive.response(), headers=archive.get_headers())
return self._download_collection(trans, id)

@router.get(
"/api/dataset_collections/{id}/download",
Expand All @@ -644,8 +643,7 @@ def download_dataset_collection(
"""Download the content of a history dataset collection as a `zip` archive
while maintaining approximate collection structure.
"""
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
return StreamingResponse(archive.response(), headers=archive.get_headers())
return self._download_collection(trans, id)

@router.post(
"/api/histories/{history_id}/contents/dataset_collections/{id}/prepare_download",
Expand Down Expand Up @@ -1033,3 +1031,7 @@ def materialize_to_history(
)
rval = self.service.materialize(trans, materialize_request)
return rval

def _download_collection(self, trans, id):
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
return StreamingResponse(archive.response(), headers=archive.get_headers())

0 comments on commit b0bbfde

Please sign in to comment.