Author: roidelapluie Date: 2007-08-29 22:42:28 +0200 (Wed, 29 Aug 2007) New Revision: 8595
Modified: branches/gajim_0.11.1/src/common/logger.py Log: Prevent a TB when a jid is in mem but not in DB (is has been removed while gajim was running). Fix #3073.
Modified: branches/gajim_0.11.1/src/common/logger.py =================================================================== --- branches/gajim_0.11.1/src/common/logger.py 2007-08-29 20:40:32 UTC (rev 8594) +++ branches/gajim_0.11.1/src/common/logger.py 2007-08-29 20:42:28 UTC (rev 8595) @@ -169,19 +169,21 @@ jid = jid.split('/', 1)[0] # remove the resource if jid in self.jids_already_in: # we already have jids in DB self.cur.execute('SELECT jid_id FROM jids WHERE jid=?', [jid]) - jid_id = self.cur.fetchone()[0] - else: # oh! a new jid :), we add it now - if typestr == 'ROOM': - typ = constants.JID_ROOM_TYPE - else: - typ = constants.JID_NORMAL_TYPE - self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid, typ)) - try: - self.con.commit() - except sqlite.OperationalError, e: - print >> sys.stderr, str(e) - jid_id = self.cur.lastrowid - self.jids_already_in.append(jid) + row = self.cur.fetchone() + if row: + return row[0] + # oh! a new jid :), we add it now + if typestr == 'ROOM': + typ = constants.JID_ROOM_TYPE + else: + typ = constants.JID_NORMAL_TYPE + self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid, typ)) + try: + self.con.commit() + except sqlite.OperationalError, e: + print >> sys.stderr, str(e) + jid_id = self.cur.lastrowid + self.jids_already_in.append(jid) return jid_id def convert_human_values_to_db_api_values(self, kind, show):