WebBrowser/SafeBrowsing/SafeBrowsingCache.py

changeset 5853
e45a570528a4
parent 5847
fd1262c3fa79
child 6048
82ad8ec9548c
equal deleted inserted replaced
5852:3aad40446c29 5853:e45a570528a4
179 179
180 create_full_hash_value_idx = """ 180 create_full_hash_value_idx = """
181 CREATE INDEX idx_full_hash_value ON full_hash (value) 181 CREATE INDEX idx_full_hash_value ON full_hash (value)
182 """ 182 """
183 drop_full_hash_value_idx = """DROP INDEX IF EXISTS idx_full_hash_value""" 183 drop_full_hash_value_idx = """DROP INDEX IF EXISTS idx_full_hash_value"""
184
185 maxProcessEventsTime = 500
184 186
185 def __init__(self, dbPath, parent=None): 187 def __init__(self, dbPath, parent=None):
186 """ 188 """
187 Constructor 189 Constructor
188 190
297 threatEntryType = query.value(2) 299 threatEntryType = query.value(2)
298 hasExpired = bool(query.value(3)) 300 hasExpired = bool(query.value(3))
299 threatList = ThreatList(threatType, platformType, 301 threatList = ThreatList(threatType, platformType,
300 threatEntryType) 302 threatEntryType)
301 output.append((threatList, hasExpired)) 303 output.append((threatList, hasExpired))
304 QCoreApplication.processEvents(QEventLoop.AllEvents,
305 self.maxProcessEventsTime)
302 del query 306 del query
303 finally: 307 finally:
304 db.commit() 308 db.commit()
305 309
306 return output 310 return output
341 threatEntryType = query.value(3) 345 threatEntryType = query.value(3)
342 negativeCacheExpired = bool(query.value(4)) 346 negativeCacheExpired = bool(query.value(4))
343 threatList = ThreatList(threatType, platformType, 347 threatList = ThreatList(threatType, platformType,
344 threatEntryType) 348 threatEntryType)
345 output.append((threatList, fullHash, negativeCacheExpired)) 349 output.append((threatList, fullHash, negativeCacheExpired))
350 QCoreApplication.processEvents(QEventLoop.AllEvents,
351 self.maxProcessEventsTime)
346 del query 352 del query
347 finally: 353 finally:
348 db.commit() 354 db.commit()
349 355
350 return output 356 return output
518 threatEntryType = query.value(2) 524 threatEntryType = query.value(2)
519 clientState = query.value(3) 525 clientState = query.value(3)
520 threatList = ThreatList(threatType, platformType, 526 threatList = ThreatList(threatType, platformType,
521 threatEntryType) 527 threatEntryType)
522 output.append((threatList, clientState)) 528 output.append((threatList, clientState))
529 QCoreApplication.processEvents(QEventLoop.AllEvents,
530 self.maxProcessEventsTime)
523 del query 531 del query
524 finally: 532 finally:
525 db.commit() 533 db.commit()
526 534
527 return output 535 return output
638 646
639 query.exec_() 647 query.exec_()
640 648
641 while query.next(): 649 while query.next():
642 sha256Hash.addData(query.value(0)) 650 sha256Hash.addData(query.value(0))
643 QCoreApplication.processEvents(QEventLoop.AllEvents, 200) 651 QCoreApplication.processEvents(QEventLoop.AllEvents,
652 self.maxProcessEventsTime)
644 del query 653 del query
645 finally: 654 finally:
646 db.commit() 655 db.commit()
647 656
648 checksum = bytes(sha256Hash.result()) 657 checksum = bytes(sha256Hash.result())
678 query.addBindValue(threatList.threatType) 687 query.addBindValue(threatList.threatType)
679 query.addBindValue(threatList.platformType) 688 query.addBindValue(threatList.platformType)
680 query.addBindValue(threatList.threatEntryType) 689 query.addBindValue(threatList.threatEntryType)
681 query.exec_() 690 query.exec_()
682 del query 691 del query
692 QCoreApplication.processEvents(QEventLoop.AllEvents,
693 self.maxProcessEventsTime)
683 finally: 694 finally:
684 db.commit() 695 db.commit()
685 696
686 def getHashPrefixValuesToRemove(self, threatList, indexes): 697 def getHashPrefixValuesToRemove(self, threatList, indexes):
687 """ 698 """
719 while query.next(): 730 while query.next():
720 if index in indexes: 731 if index in indexes:
721 prefix = bytes(query.value(0)) 732 prefix = bytes(query.value(0))
722 output.append(prefix) 733 output.append(prefix)
723 index += 1 734 index += 1
735 QCoreApplication.processEvents(QEventLoop.AllEvents,
736 self.maxProcessEventsTime)
724 del query 737 del query
725 finally: 738 finally:
726 db.commit() 739 db.commit()
727 740
728 return output 741 return output
764 for prefix in removeBatch: 777 for prefix in removeBatch:
765 query.addBindValue(QByteArray(prefix), 778 query.addBindValue(QByteArray(prefix),
766 QSql.In | QSql.Binary) 779 QSql.In | QSql.Binary)
767 query.exec_() 780 query.exec_()
768 del query 781 del query
782 QCoreApplication.processEvents(
783 QEventLoop.AllEvents, self.maxProcessEventsTime)
769 finally: 784 finally:
770 db.commit() 785 db.commit()

eric ide

mercurial