re-connect to DB after upgrades (upgrade can modify DB structure)
This commit is contained in:
		
							parent
							
								
									6db26bf444
								
							
						
					
					
						commit
						1f72608d20
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		|  | @ -99,6 +99,7 @@ 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) | ||||||
|  | @ -109,6 +110,8 @@ class Logger: | ||||||
| 	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() | ||||||
|  | @ -118,6 +121,7 @@ class Logger: | ||||||
| 	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…
	
	Add table
		
		Reference in a new issue