From c30dfc63437a81c9fdeda27a2ad02449b3a122d3 Mon Sep 17 00:00:00 2001 From: Paul Culley Date: Thu, 9 Jan 2020 11:38:16 -0600 Subject: [PATCH] Fix db to warn/prevent opening newer schema versions (#945) --- gramps/gen/db/generic.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index ba445c9d8..5c160ed24 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -47,6 +47,7 @@ from . import (DbReadBase, DbWriteBase, DbUndo, DBLOGNAME, DBUNDOFN, REPOSITORY_KEY, NOTE_KEY, TAG_KEY, TXNADD, TXNUPD, TXNDEL, KEY_TO_NAME_MAP, DBMODE_R, DBMODE_W) from .utils import write_lock_file, clear_lock_file +from .exceptions import DbVersionError from ..errors import HandleError from ..utils.callback import Callback from ..updatecallback import UpdateCallback @@ -659,6 +660,12 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): self.db_is_open = True + # Check on db version to see if too new + dbversion = int(self._get_metadata('version', default='0')) + if dbversion > self.VERSION[0]: + self.close() + raise DbVersionError(dbversion, 18, self.VERSION[0]) + def _close(self): """ Close database backend.