From 45c5a384f1c4803dbb8239c7ef2eef40df4fc144 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 25 Sep 2024 16:50:00 +0200 Subject: [PATCH] Raise exception if CompressedFile used on incompatible file Surprised (or not actually ...) that mypy didn't catch this. --- lib/galaxy/util/compression_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/galaxy/util/compression_utils.py b/lib/galaxy/util/compression_utils.py index d54c0ffcbc24..576e62623f99 100644 --- a/lib/galaxy/util/compression_utils.py +++ b/lib/galaxy/util/compression_utils.py @@ -188,6 +188,8 @@ def __init__(self, file_path: StrPath, mode: str = "r") -> None: self.file_type = "tar" elif zipfile.is_zipfile(file_path) and not file_path_str.endswith(".jar"): self.file_type = "zip" + else: + raise Exception("File must be valid zip or tar file.") self.file_name = os.path.splitext(os.path.basename(file_path))[0] if self.file_name.endswith(".tar"): self.file_name = os.path.splitext(self.file_name)[0]