From 7a07d32b494959bf2eb9eebf2042311015f686f7 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 29 Jan 2010 19:02:54 +0100 Subject: [PATCH] prevent wrong spliting of db --- src/common/optparser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/optparser.py b/src/common/optparser.py index 3b6a59ac0..15fd86741 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -890,9 +890,14 @@ class OptionsParser: con = sqlite.connect(logger.LOG_DB_FILE) os.chdir(back) cur = con.cursor() + cur.execute('''SELECT name FROM sqlite_master WHERE type = 'table';''') + tables = cur.fetchall() # we get [(u'jids',), (u'unread_messages',), ... + tables = [t[0] for t in tables] cur.execute("ATTACH DATABASE '%s' AS cache" % logger.CACHE_DB_PATH) for table in ('caps_cache', 'rooms_last_message_time', 'roster_entry', 'roster_group', 'transports_cache'): + if table not in tables: + continue try: cur.executescript( 'INSERT INTO cache.%s SELECT * FROM %s;' % (table, table))