fix insert hash for force not to do a commit
This commit is contained in:
parent
2a92b1f747
commit
2542719378
|
@ -26,13 +26,16 @@ class ReportHash(db.Model):
|
||||||
hash3.comment = """The normalized name of the hash."""
|
hash3.comment = """The normalized name of the hash."""
|
||||||
|
|
||||||
|
|
||||||
def insert_hash(bfile):
|
def insert_hash(bfile, commit=True):
|
||||||
hash3 = hashlib.sha3_256(bfile).hexdigest()
|
hash3 = hashlib.sha3_256(bfile).hexdigest()
|
||||||
db_hash = ReportHash(hash3=hash3)
|
db_hash = ReportHash(hash3=hash3)
|
||||||
db.session.add(db_hash)
|
db.session.add(db_hash)
|
||||||
|
if commit:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
|
|
||||||
|
return hash3
|
||||||
|
|
||||||
|
|
||||||
def verify_hash(bfile):
|
def verify_hash(bfile):
|
||||||
hash3 = hashlib.sha3_256(bfile.read()).hexdigest()
|
hash3 = hashlib.sha3_256(bfile.read()).hexdigest()
|
||||||
|
|
Reference in New Issue