Dont try to insert if JID is already in DB

- This is added because even an ignored INSERT raises the
autoincrement value of the table.
This means the jid id gets high really fast.
This commit is contained in:
Philipp Hörist 2017-08-08 17:29:17 +02:00
parent f88e8d835b
commit c53e2b1bb9
1 changed files with 3 additions and 0 deletions

View File

@ -1079,10 +1079,13 @@ class Logger:
:param type_: A JIDConstant
"""
if jid in self.jids_already_in:
return
if kind in (KindConstant.GC_MSG, KindConstant.GCSTATUS):
type_ = JIDConstant.ROOM_TYPE
sql = 'INSERT OR IGNORE INTO jids (jid, type) VALUES (?, ?)'
self.con.execute(sql, (jid, type_))
self.jids_already_in.append(jid)
self._timeout_commit()
def insert_into_logs(self, jid, time_, kind, unread=True, **kwargs):