Skip to content

Commit

Permalink
Merge pull request #18094 from jdavcs/240_emptycolldownload
Browse files Browse the repository at this point in the history
[24.0] Raise exception if collection elements missing during download
  • Loading branch information
mvdbeek authored May 12, 2024
2 parents 375268c + f218a39 commit 8ff7e2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/managers/hdcas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Dict

from galaxy import model
from galaxy.exceptions import RequestParameterInvalidException
from galaxy.managers import (
annotatable,
base,
Expand Down Expand Up @@ -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:
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 8ff7e2f

Please sign in to comment.