Rev1909, Rebuild content.db on error

This commit is contained in:
shortcutme 2017-02-15 13:35:24 +01:00
parent f5fb6b83ff
commit 23dc8e063c
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
2 changed files with 12 additions and 3 deletions

View File

@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.5.2"
self.rev = 1905
self.rev = 1909
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"

View File

@ -1,8 +1,10 @@
import time
import os
from Db import Db
from Config import config
from Plugin import PluginManager
from Debug import Debug
@PluginManager.acceptPlugins
@ -10,8 +12,15 @@ class ContentDb(Db):
def __init__(self, path):
Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path)
self.foreign_keys = True
self.schema = self.getSchema()
self.checkTables()
try:
self.schema = self.getSchema()
self.checkTables()
except Exception, err:
self.log.error("Error loading content.db: %s, rebuilding..." % Debug.formatException(err))
self.close()
os.unlink(path) # Remove and try again
self.schema = self.getSchema()
self.checkTables()
self.site_ids = {}
self.sites = {}