From 2542719378066cb64631781c68e8d21b7a97dadf Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 7 Feb 2022 14:03:01 +0100 Subject: [PATCH] fix insert hash for force not to do a commit --- ereuse_devicehub/resources/hash_reports.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/resources/hash_reports.py b/ereuse_devicehub/resources/hash_reports.py index f44a79be..1cb7f491 100644 --- a/ereuse_devicehub/resources/hash_reports.py +++ b/ereuse_devicehub/resources/hash_reports.py @@ -26,12 +26,15 @@ class ReportHash(db.Model): hash3.comment = """The normalized name of the hash.""" -def insert_hash(bfile): +def insert_hash(bfile, commit=True): hash3 = hashlib.sha3_256(bfile).hexdigest() db_hash = ReportHash(hash3=hash3) db.session.add(db_hash) - db.session.commit() - db.session.flush() + if commit: + db.session.commit() + db.session.flush() + + return hash3 def verify_hash(bfile):