Added exception handling for invalid dbschema.json files
This commit is contained in:
parent
89fb282be5
commit
aee83605ab
1 changed files with 6 additions and 2 deletions
|
@ -34,8 +34,12 @@ class SiteStorage:
|
||||||
|
|
||||||
# Load db from dbschema.json
|
# Load db from dbschema.json
|
||||||
def openDb(self, check=True):
|
def openDb(self, check=True):
|
||||||
|
try:
|
||||||
schema = self.loadJson("dbschema.json")
|
schema = self.loadJson("dbschema.json")
|
||||||
db_path = self.getPath(schema["db_file"])
|
db_path = self.getPath(schema["db_file"])
|
||||||
|
except Exception, err:
|
||||||
|
raise Exception("dbschema.json is not a valid JSON: %s", err)
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0: # Not exist or null
|
if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0: # Not exist or null
|
||||||
self.rebuildDb()
|
self.rebuildDb()
|
||||||
|
|
Loading…
Reference in a new issue