Merge pull request #18094 from jdavcs/240_emptycolldownload

[24.0] Raise exception if collection elements missing during download
This commit is contained in:
Marius van den Beek
2024-05-12 21:26:24 +02:00
committed by GitHub
3 changed files with 12 additions and 4 deletions
@@ -18,6 +18,8 @@ const rerunUrl = computed(() =>
const showCollectionDetailsUrl = computed(() =>
props.dsc.job_source_type == "Job" ? `/jobs/${props.dsc.job_source_id}/view` : null
);
const disableDownload = props.dsc.populated_state !== "ok";
function onDownload() {
window.location.href = downloadUrl.value;
}
@@ -28,6 +30,7 @@ function onDownload() {
<b-button-group>
<b-button
title="Download Collection"
:disabled="disableDownload"
class="rounded-0 text-decoration-none"
size="sm"
variant="link"
+3
View File
@@ -9,6 +9,7 @@ import logging
from typing import Dict
from galaxy import model
from galaxy.exceptions import RequestParameterInvalidException
from galaxy.managers import (
annotatable,
base,
@@ -40,6 +41,8 @@ def stream_dataset_collection(dataset_collection_instance, upstream_mod_zip=Fals
def write_dataset_collection(dataset_collection_instance, archive):
if not dataset_collection_instance.collection.populated_optimized:
raise RequestParameterInvalidException("Attempt to write dataset collection that has not been populated yet")
names, hdas = get_hda_and_element_identifiers(dataset_collection_instance)
for name, hda in zip(names, hdas):
if hda.state != hda.states.OK:
@@ -626,8 +626,7 @@ class FastAPIHistoryContents:
"""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 @@ class FastAPIHistoryContents:
"""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 @@ class FastAPIHistoryContents:
)
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())