Added exception handling for invalid dbschema.json files

This commit is contained in:
Barrabin Fc. ⚑ 2016-03-03 20:40:26 -03:00
parent 89fb282be5
commit aee83605ab

View file

@ -34,8 +34,12 @@ class SiteStorage:
# Load db from dbschema.json
def openDb(self, check=True):
schema = self.loadJson("dbschema.json")
db_path = self.getPath(schema["db_file"])
try:
schema = self.loadJson("dbschema.json")
db_path = self.getPath(schema["db_file"])
except Exception, err:
raise Exception("dbschema.json is not a valid JSON: %s", err)
if check:
if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0: # Not exist or null
self.rebuildDb()