fix insert hash for force not to do a commit

This commit is contained in:
Cayo Puigdefabregas 2022-02-07 14:03:01 +01:00
parent 2a92b1f747
commit 2542719378
1 changed files with 6 additions and 3 deletions

View File

@ -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):