# HG changeset patch # User Goffi # Date 1561114776 -7200 # Node ID 17c61d09a85b8254c51107d94f462ab492188519 # Parent c90a2586fdf99d580d9144f6c42b20893981e40e memory (sqlite): exit with an error if current db version is higher than version expected in current code diff -r c90a2586fdf9 -r 17c61d09a85b sat/memory/sqlite.py --- a/sat/memory/sqlite.py Fri Jun 21 11:37:51 2019 +0200 +++ b/sat/memory/sqlite.py Fri Jun 21 12:59:36 2019 +0200 @@ -21,7 +21,6 @@ from sat.core.constants import Const as C from sat.core import exceptions from sat.core.log import getLogger -log = getLogger(__name__) from sat.memory.crypto import BlockCipher, PasswordHasher from sat.tools.config import fixConfigOption from twisted.enterprise import adbapi @@ -29,6 +28,7 @@ from twisted.words.protocols.jabber import jid from twisted.python import failure from collections import OrderedDict +import sys import re import os.path import cPickle as pickle @@ -36,6 +36,8 @@ import sqlite3 import json +log = getLogger(__name__) + CURRENT_DB_VERSION = 8 # XXX: DATABASE schemas are used in the following way: @@ -1053,6 +1055,13 @@ log.warning(_(u"Here are the commands that should fix the situation, use at your own risk (do a backup before modifying database), you can go to SàT's MUC room at sat@chat.jabberfr.org for help\n### SQL###\n%s\n### END SQL ###\n") % u'\n'.join("%s;" % statement for statement in update_raw)) raise exceptions.DatabaseError("Database mismatch") else: + if local_version > CURRENT_DB_VERSION: + log.error(_( + u"You database version is higher than the one used in this SàT " + u"version, are you using several version at the same time? We " + u"can't run SàT with this database.")) + sys.exit(1) + # Database is not up-to-date, we'll do the update if force_update: log.info(_("Database content needs a specific processing, local database will be updated"))