fix DB thread issue

This commit is contained in:
Muzahid 2021-02-09 20:09:19 +05:30
parent 3fa531c223
commit 42007d02ad
Signed by untrusted user: cis-muzahid
GPG Key ID: 1DC85E7D3AB613EA
1 changed files with 6 additions and 6 deletions

View File

@ -158,6 +158,8 @@ class UpgradeDB():
self.cur.execute( self.cur.execute(
'''CREATE TABLE objectprocessorqueue''' '''CREATE TABLE objectprocessorqueue'''
''' (objecttype int, data blob, UNIQUE(objecttype, data) ON CONFLICT REPLACE)''') ''' (objecttype int, data blob, UNIQUE(objecttype, data) ON CONFLICT REPLACE)''')
logger.debug(
'Finished dropping and recreating the inventory table.')
def upgrade_schema_data_7(self): def upgrade_schema_data_7(self):
""" """
@ -174,8 +176,11 @@ class UpgradeDB():
'''delete from inventory where objecttype = 1;''') '''delete from inventory where objecttype = 1;''')
self.cur.execute( self.cur.execute(
'''delete from pubkeys;''') '''delete from pubkeys;''')
# Any sending messages for which we *thought* that we had
# the pubkey must be rechecked.
self.cur.execute( self.cur.execute(
'''UPDATE sent SET status='msgqueued' WHERE status='doingmsgpow' or status='badkey';''') '''UPDATE sent SET status='msgqueued' WHERE status='doingmsgpow' or status='badkey';''')
logger.debug('Finished clearing currently held pubkeys.')
def upgrade_schema_data_8(self): def upgrade_schema_data_8(self):
""" """
@ -204,7 +209,6 @@ class UpgradeDB():
' combining the pubkeyretrynumber and msgretrynumber' ' combining the pubkeyretrynumber and msgretrynumber'
' fields into the retrynumber field and adding the' ' fields into the retrynumber field and adding the'
' sleeptill and ttl fields...') ' sleeptill and ttl fields...')
self.cur.execute( self.cur.execute(
'''CREATE TEMPORARY TABLE sent_backup''' '''CREATE TEMPORARY TABLE sent_backup'''
''' (msgid blob, toaddress text, toripe blob, fromaddress text, subject text, message text,''' ''' (msgid blob, toaddress text, toripe blob, fromaddress text, subject text, message text,'''
@ -228,7 +232,7 @@ class UpgradeDB():
logger.debug('In messages.dat database, adding address field to the pubkeys table.') logger.debug('In messages.dat database, adding address field to the pubkeys table.')
# We're going to have to calculate the address for each row in the pubkeys # We're going to have to calculate the address for each row in the pubkeys
# table. Then we can take out the hash field. # table. Then we can take out the hash field.
self.cur.execute('''ALTER TABLE pubkeys ADD address text DEFAULT ''') self.cur.execute('''ALTER TABLE pubkeys ADD address text DEFAULT '' ''')
self.cur.execute('''SELECT hash, addressversion FROM pubkeys''') self.cur.execute('''SELECT hash, addressversion FROM pubkeys''')
queryResult = self.cur.fetchall() queryResult = self.cur.fetchall()
from addresses import encodeAddress from addresses import encodeAddress
@ -258,7 +262,6 @@ class UpgradeDB():
logger.debug( logger.debug(
'In messages.dat database, done adding address field to the pubkeys table' 'In messages.dat database, done adding address field to the pubkeys table'
' and removing the hash field.') ' and removing the hash field.')
# self.cur.execute('''update settings set value=10 WHERE key='version';''')
def upgrade_schema_data_10(self): def upgrade_schema_data_10(self):
""" """
@ -277,8 +280,6 @@ class UpgradeDB():
self.cur.execute( self.cur.execute(
'''INSERT INTO addressbook SELECT label, address FROM old_addressbook;''') '''INSERT INTO addressbook SELECT label, address FROM old_addressbook;''')
self.cur.execute('''DROP TABLE old_addressbook''') self.cur.execute('''DROP TABLE old_addressbook''')
# self.cur.execute('''update settings set value=11 WHERE key='version';''')
class sqlThread(threading.Thread, UpgradeDB): class sqlThread(threading.Thread, UpgradeDB):
"""A thread for all SQL operations""" """A thread for all SQL operations"""
@ -438,7 +439,6 @@ class sqlThread(threading.Thread, UpgradeDB):
'''update sent set status='broadcastqueued' where status='broadcastpending' ''') '''update sent set status='broadcastqueued' where status='broadcastpending' ''')
self.conn.commit() self.conn.commit()
# Upgrade Db with respect to their versions
self.upgrade_to_latest(self.cur) self.upgrade_to_latest(self.cur)
# Are you hoping to add a new option to the keys.dat file of existing # Are you hoping to add a new option to the keys.dat file of existing