From 9cfa0fc5565443df8a6dc91c5cce834e7996fb84 Mon Sep 17 00:00:00 2001 From: themoonisacheese Date: Thu, 19 Oct 2023 18:07:23 +0200 Subject: [PATCH] close files properly, handle xci correctly. --- README.md | 2 +- verif.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e7d69438..9115ba39 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ cd autoverif python3 -m venv .venv #Windows: -.venv.\Scripts\activate.bat +.venv\Scripts\activate.bat #Linux: source .venv/bin/activate diff --git a/verif.py b/verif.py index 77485a35..2fded8d5 100644 --- a/verif.py +++ b/verif.py @@ -42,15 +42,25 @@ def verify(file): tmpfolder =os.path.join(dir,'tmp') feed='' buffer = 65536 - - f = Fs.Nsp(filename, 'rb') - + if filename.lower().endswith('.nsp') or filename.lower().endswith('.nsz'): + f = Fs.Nsp(filename, 'rb') + elif filename.lower().endswith('.xcz') or filename.lower().endswith('.xci'): + f = Fs.Xci(filename, 'rb') + else: + raise Exception("{1} does not have the appropriate extension".format(filename)) + + check,feed=f.verify() + if check == False: + f.flush() + f.close() return False verdict,headerlist,feed=f.verify_sig(feed,tmpfolder) if verdict == False: + f.flush() + f.close() return False print(filename) if filename.endswith('.nsz') :