better handle badly-written DBs
This commit is contained in:
parent
51a7c96ea0
commit
8de4719701
1 changed files with 12 additions and 5 deletions
|
@ -42,11 +42,18 @@ class EventModel(object):
|
||||||
if not name.isalpha():
|
if not name.isalpha():
|
||||||
self.log.warning("%s db file name is not valid: it must be alphabetic only", str(db_file.name))
|
self.log.warning("%s db file name is not valid: it must be alphabetic only", str(db_file.name))
|
||||||
continue
|
continue
|
||||||
self._dbs[name] = TinyDB(
|
try:
|
||||||
str(db_file),
|
self._dbs[name] = TinyDB(
|
||||||
storage=ReadOnlyMiddleware(JSONStorage),
|
str(db_file),
|
||||||
default_table='actions'
|
storage=ReadOnlyMiddleware(JSONStorage),
|
||||||
)
|
default_table='actions'
|
||||||
|
)
|
||||||
|
except ReadOnlyException:
|
||||||
|
# TinyDB adds the default_table if it is not present at read time.
|
||||||
|
# This should not happen at all for a ReadOnlyMiddleware db, but at least we can notice it and
|
||||||
|
# properly signal this to the user.
|
||||||
|
self.log.error("Could not load db %s: 'actions' table is missing", db_file.name)
|
||||||
|
continue
|
||||||
|
|
||||||
self.log.debug('Loaded %d databases: %s', len(self._dbs), ','.join(self._dbs.keys()))
|
self.log.debug('Loaded %d databases: %s', len(self._dbs), ','.join(self._dbs.keys()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue