aboutsummaryrefslogtreecommitdiffstats
path: root/tagit/widgets
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-03-04 16:00:46 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-03-04 16:00:46 +0100
commit01a4c2fc4bcbcce26c29dc9771dedeef5256156b (patch)
treeaafea6125f413f6862bb79ad9c9ef5b35a6b7dd3 /tagit/widgets
parent9bdf4d104a299577634061bcf698d1c9e5708cce (diff)
downloadtagit-01a4c2fc4bcbcce26c29dc9771dedeef5256156b.tar.gz
tagit-01a4c2fc4bcbcce26c29dc9771dedeef5256156b.tar.bz2
tagit-01a4c2fc4bcbcce26c29dc9771dedeef5256156b.zip
schema requirements checking
Diffstat (limited to 'tagit/widgets')
-rw-r--r--tagit/widgets/session.py12
1 files changed, 6 insertions, 6 deletions
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