re-connect to DB after upgrades (upgrade can modify DB structure)
This commit is contained in:
parent
6db26bf444
commit
1f72608d20
|
@ -99,25 +99,29 @@ constants = Constants()
|
||||||
class Logger:
|
class Logger:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.jids_already_in = [] # holds jids that we already have in DB
|
self.jids_already_in = [] # holds jids that we already have in DB
|
||||||
|
self.con = None
|
||||||
|
|
||||||
if not os.path.exists(LOG_DB_PATH):
|
if not os.path.exists(LOG_DB_PATH):
|
||||||
# this can happen only the first time (the time we create the db)
|
# this can happen only the first time (the time we create the db)
|
||||||
# db is not created here but in src/common/checks_paths.py
|
# db is not created here but in src/common/checks_paths.py
|
||||||
return
|
return
|
||||||
self.init_vars()
|
self.init_vars()
|
||||||
|
|
||||||
def init_vars(self):
|
def init_vars(self):
|
||||||
# if locked, wait up to 20 sec to unlock
|
# if locked, wait up to 20 sec to unlock
|
||||||
# before raise (hopefully should be enough)
|
# before raise (hopefully should be enough)
|
||||||
|
if self.con:
|
||||||
|
self.con.close()
|
||||||
self.con = sqlite.connect(LOG_DB_PATH, timeout = 20.0,
|
self.con = sqlite.connect(LOG_DB_PATH, timeout = 20.0,
|
||||||
isolation_level = 'IMMEDIATE')
|
isolation_level = 'IMMEDIATE')
|
||||||
self.cur = self.con.cursor()
|
self.cur = self.con.cursor()
|
||||||
|
|
||||||
self.get_jids_already_in_db()
|
self.get_jids_already_in_db()
|
||||||
|
|
||||||
def get_jids_already_in_db(self):
|
def get_jids_already_in_db(self):
|
||||||
self.cur.execute('SELECT jid FROM jids')
|
self.cur.execute('SELECT jid FROM jids')
|
||||||
rows = self.cur.fetchall() # list of tupples: [(u'aaa@bbb',), (u'cc@dd',)]
|
rows = self.cur.fetchall() # list of tupples: [(u'aaa@bbb',), (u'cc@dd',)]
|
||||||
|
self.jids_already_in = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
# row[0] is first item of row (the only result here, the jid)
|
# row[0] is first item of row (the only result here, the jid)
|
||||||
self.jids_already_in.append(row[0])
|
self.jids_already_in.append(row[0])
|
||||||
|
|
|
@ -147,6 +147,7 @@ class OptionsParser:
|
||||||
if old < [0, 10, 1, 3] and new >= [0, 10, 1, 3]:
|
if old < [0, 10, 1, 3] and new >= [0, 10, 1, 3]:
|
||||||
self.update_config_to_01013()
|
self.update_config_to_01013()
|
||||||
|
|
||||||
|
gajim.logger.init_vars()
|
||||||
gajim.config.set('version', new_version)
|
gajim.config.set('version', new_version)
|
||||||
|
|
||||||
def update_config_x_to_09(self):
|
def update_config_x_to_09(self):
|
||||||
|
|
Loading…
Reference in New Issue