diff --git a/lib/galaxy/managers/hdcas.py b/lib/galaxy/managers/hdcas.py index ad5bcda58e8b..59b1fc4a5d46 100644 --- a/lib/galaxy/managers/hdcas.py +++ b/lib/galaxy/managers/hdcas.py @@ -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): diff --git a/lib/galaxy/webapps/galaxy/api/history_contents.py b/lib/galaxy/webapps/galaxy/api/history_contents.py index bfab8f0ef448..1bb1e21ade12 100644 --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -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", @@ -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", @@ -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())