diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index 259b8e08c68..ff089c4c386 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -323,7 +323,9 @@ class Registry(object): if sniff_compressed_types is None: sniff_compressed_types = getattr(self.config, "sniff_compressed_dynamic_datatypes_default", True) if not sniff_compressed_types: - attributes["sniff_prefix"] = lambda self, file_prefix: False + # Disable sniff on this type unless in validate_mode(). + attributes["sniff_compressed"] = False + compressed_datatype_class = type(auto_compressed_type_name, (datatype_class, binary.CompressedArchive, ), attributes) if edam_format: compressed_datatype_class.edam_format = edam_format diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index 2b1509d1445..50f9a2cc78d 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -605,13 +605,26 @@ class FilePrefix(object): def build_sniff_from_prefix(klass): + # Build and attach a sniff function to this class (klass) from the sniff_prefix function + # expected to be defined for the class. def auto_sniff(self, filename): file_prefix = FilePrefix(filename) datatype_compressed = getattr(self, "compressed", False) if file_prefix.compressed_format and not datatype_compressed: return False - if datatype_compressed and not file_prefix.compressed_format: - return False + if datatype_compressed: + if not file_prefix.compressed_format: + # This not a compressed file we are looking but the type expects it to be + # must return False. + return False + + if not getattr(klass, "sniff_compressed", True) and not self.validate_mode(): + # This datatype indicates that it shouldn't be auto-sniffed so return False. + # Do not take this shortcut if validate_mode is True, in that case we aren't + # trying to find a datatype for a file we are trying to verify a datatype + # selection and so should execute the underlying sniff_prefix. + return False + if hasattr(self, "compressed_format"): if self.compressed_format != file_prefix.compressed_format: return False