From e2a511b37944fe22f5d91bdec9d32dc52ee26811 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Wed, 22 Oct 2008 15:48:35 +0000 Subject: [PATCH] inform user when databas is malformed. Fixes #4428 --- src/common/connection_handlers.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 86004fa7b5..c235cc5242 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1837,6 +1837,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, subject=subject) except exceptions.PysqliteOperationalError, e: self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + except exceptions.DatabaseMalformed: + pritext = _('Database Error') + sectext = _('The database file (%s) cannot be read. Try to repair ' + 'it or remove it (all history will be lost).') % \ + common.logger.LOG_DB_PATH + self.dispatch('ERROR', (pritext, sectext)) self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, tim, session)) @@ -1877,6 +1883,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, gajim.logger.write('gc_msg', frm, msgtxt, tim=tim) except exceptions.PysqliteOperationalError, e: self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + except exceptions.DatabaseMalformed: + pritext = _('Database Error') + sectext = _('The database file (%s) cannot be read. Try to repair ' + 'it or remove it (all history will be lost).') % \ + common.logger.LOG_DB_PATH + self.dispatch('ERROR', (pritext, sectext)) def dispatch_invite_message(self, invite, frm): item = invite.getTag('invite') @@ -2059,6 +2071,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, gajim.logger.write('gcstatus', who, st, show) except exceptions.PysqliteOperationalError, e: self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + except exceptions.DatabaseMalformed: + pritext = _('Database Error') + sectext = _('The database file (%s) cannot be read. Try to ' + 'repair it or remove it (all history will be lost).') % \ + common.logger.LOG_DB_PATH + self.dispatch('ERROR', (pritext, sectext)) if avatar_sha or avatar_sha == '': if avatar_sha == '': # contact has no avatar @@ -2178,6 +2196,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, gajim.logger.write('status', jid_stripped, status, show) except exceptions.PysqliteOperationalError, e: self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + except exceptions.DatabaseMalformed: + pritext = _('Database Error') + sectext = _('The database file (%s) cannot be read. Try to ' + 'repair it or remove it (all history will be lost).') % \ + common.logger.LOG_DB_PATH + self.dispatch('ERROR', (pritext, sectext)) our_jid = gajim.get_jid_from_account(self.name) if jid_stripped == our_jid and resource == self.server_resource: # We got our own presence -- GitLab