From c05c65b1b3fc514da8f1983c76c1f2a062688a60 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 21 Jun 2019 12:59:36 +0200 Subject: [PATCH] memory (sqlite): exit with an error if current db version is higher than version expected in current code --- sat/memory/sqlite.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sat/memory/sqlite.py b/sat/memory/sqlite.py index 482b13a9..94cb504f 100644 --- a/sat/memory/sqlite.py +++ b/sat/memory/sqlite.py @@ -21,7 +21,6 @@ from sat.core.i18n import _ 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.internet import defer 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 hashlib import sqlite3 import json +log = getLogger(__name__) + CURRENT_DB_VERSION = 8 # XXX: DATABASE schemas are used in the following way: @@ -1053,6 +1055,13 @@ class Updater(object): 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"))