From 01a4c2fc4bcbcce26c29dc9771dedeef5256156b Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sat, 4 Mar 2023 16:00:46 +0100 Subject: schema requirements checking --- tagit/widgets/session.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tagit/widgets') diff --git a/tagit/widgets/session.py b/tagit/widgets/session.py index c233a15..30dfe51 100644 --- a/tagit/widgets/session.py +++ b/tagit/widgets/session.py @@ -68,13 +68,13 @@ class Session(Widget): # open BSFS storage store = bsfs.Open(cfg('session', 'bsfs')) # check storage schema - # FIXME: how to properly load the required schema? - with open(os.path.join(os.path.dirname(__file__), '..', 'apps', 'port-schema.nt'), 'rt') as ifile: + with open(resource_find('required_schema.nt'), 'rt') as ifile: required_schema = bsfs.schema.from_string(ifile.read()) - # FIXME: Since the store isn't persistent, we migrate to the required one here. - #if not required_schema <= store.schema: - # raise Exception('') - store.migrate(required_schema) + if not required_schema.consistent_with(store.schema): + raise Exception("The storage's schema is incompatible with tagit's requirements") + if not required_schema <= store.schema: + store.migrate(required_schema | store.schema) + # replace current with new storage self.storage = store -- cgit v1.2.3