Unverified Commit 6b55c93d authored by mvdbeek's avatar mvdbeek
Browse files

Fix collection download for bam native files

Fixes
https://sentry.galaxyproject.org/organizations/galaxy/issues/85033/?project=3&query=is%3Aunresolved&statsPeriod=14d:
```
AttributeError: 'NoneType' object has no attribute 'file_name'
  File "galaxy/webapps/galaxy/services/history_contents.py", line 482, in get_dataset_collection_archive_for_download
    return self.__stream_dataset_collection(trans, dataset_collection_instance)
  File "galaxy/webapps/galaxy/services/history_contents.py", line 503, in __stream_dataset_collection
    archive = hdcas.stream_dataset_collection(
  File "galaxy/managers/hdcas.py", line 37, in stream_dataset_collection
    write_dataset_collection(dataset_collection_instance, archive)
  File "galaxy/managers/hdcas.py", line 46, in write_dataset_collection
    for file_path, relpath in hda.datatype.to_archive(dataset=hda, name=name):
  File "galaxy/datatypes/binary.py", line 535, in to_archive
    file_paths.append(dataset.metadata.bam_index.file_name)
```
parent c5527edd
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -421,6 +421,8 @@ class BamNative(CompressedArchive, _BamOrSam):
        file_paths = []
        rel_paths.append(f"{name or dataset.file_name}.{dataset.extension}")
        file_paths.append(dataset.file_name)
        # We may or may not have a bam index file (BamNative doesn't have it, but also index generation may have failed)
        if dataset.metadata.bam_index:
            rel_paths.append(f"{name or dataset.file_name}.{dataset.extension}.bai")
            file_paths.append(dataset.metadata.bam_index.file_name)
        return zip(file_paths, rel_paths)