Skip to content

Commit

Permalink
Merge pull request #17679 from mvdbeek/fix_npz_sniffer
Browse files Browse the repository at this point in the history
[23.2] Assert that at least one file in npz zipfile ends with .npy
  • Loading branch information
mvdbeek authored Mar 13, 2024
2 parents 93eb541 + fd5fd15 commit 52ca282
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4297,9 +4297,9 @@ def __init__(self, **kwd):

def sniff(self, filename: str) -> bool:
try:
npz = np.load(filename)
if isinstance(npz, np.lib.npyio.NpzFile):
return True
with np.load(filename) as npz:
if isinstance(npz, np.lib.npyio.NpzFile) and any(f.filename.endswith(".npy") for f in npz.zip.filelist):
return True
except Exception:
return False
return False
Expand Down

0 comments on commit 52ca282

Please sign in to comment.