diff -up gwibber-3.0.0.1/gwibber/microblog/storage.py.catch_sqlite_error gwibber-3.0.0.1/gwibber/microblog/storage.py --- gwibber-3.0.0.1/gwibber/microblog/storage.py.catch_sqlite_error 2011-05-12 13:43:10.977009364 -0400 +++ gwibber-3.0.0.1/gwibber/microblog/storage.py 2011-05-12 13:59:46.707973761 -0400 @@ -41,7 +41,11 @@ class MessageManager(dbus.service.Object def setup_table(self): with self.db: schema = "rowid integer primary key autoincrement," + self.schema - self.db.execute("CREATE TABLE messages (%s)" % schema) + try: + self.db.execute("CREATE TABLE messages (%s)" % schema) + except sqlite3.OperationalError, msg: + log.logger.info("SQLite threw an error trying to setup the messages table: %s", msg) + self.db.execute("create unique index idx1 on messages (mid, account, operation, transient)") def maintenance(self): @@ -59,10 +63,16 @@ class MessageManager(dbus.service.Object log.logger.info("Found %d records in the messages stream for account %s", count, acct[0]) if count > 2000: log.logger.info("Purging old data for %s", acct[0]) - self.db.execute("DELETE FROM messages WHERE account = ? AND operation = 'receive' AND stream = 'messages' AND time IN (SELECT CAST (time AS int) FROM (SELECT time FROM messages WHERE account = ? AND operation = 'receive' AND stream = 'messages' AND time != 0 ORDER BY time ASC LIMIT (SELECT COUNT(time) FROM messages WHERE operation = 'receive' AND stream = 'messages' AND account = ? AND time != 0) - 2000) ORDER BY time ASC)", (acct[0],acct[0],acct[0])) + try: + self.db.execute("DELETE FROM messages WHERE account = ? AND operation = 'receive' AND stream = 'messages' AND time IN (SELECT CAST (time AS int) FROM (SELECT time FROM messages WHERE account = ? AND operation = 'receive' AND stream = 'messages' AND time != 0 ORDER BY time ASC LIMIT (SELECT COUNT(time) FROM messages WHERE operation = 'receive' AND stream = 'messages' AND account = ? AND time != 0) - 2000) ORDER BY time ASC)", (acct[0],acct[0],acct[0])) + except sqlite3.OperationalError, msg: + log.logger.info("DB Maintenance: SQLite threw an error: %s", msg) except: pass - self.db.execute("VACUUM") + try: + self.db.execute("VACUUM") + except sqlite3.OperationalError, msg: + log.logger.info("DB Maintenance: SQLite threw an error: %s", msg) return @@ -154,14 +164,17 @@ class StreamManager(dbus.service.Object) def setup_table(self): with self.db: - self.db.execute(""" - CREATE TABLE streams ( - id text, - name text, - account text, - operation text, - data text) - """) + try: + self.db.execute(""" + CREATE TABLE streams ( + id text, + name text, + account text, + operation text, + data text) + """) + except sqlite3.OperationalError, msg: + log.logger.info("SQLite threw an error trying to setup the streams table: %s", msg) @dbus.service.signal("com.Gwibber.Streams", signature="s") def Updated(self, data): @@ -265,15 +278,19 @@ class AccountManager(dbus.service.Object def setup_table(self): with self.db: - self.db.execute(""" - CREATE TABLE accounts ( - id text, - service text, - username text, - color text, - send integer, - receive integer, - data text)""") + try: + self.db.execute(""" + CREATE TABLE accounts ( + id text, + service text, + username text, + color text, + send integer, + receive integer, + data text)""") + except sqlite3.OperationalError, msg: + log.logger.info("SQLite threw an error trying to setup the accounts table: %s", msg) + def refresh_password_cache(self): for acct in json.loads(self.List()):