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): def __init__(self, argv):
self.version = "0.5.2" self.version = "0.5.2"
self.rev = 1905 self.rev = 1909
self.argv = argv self.argv = argv
self.action = None self.action = None
self.config_file = "zeronet.conf" self.config_file = "zeronet.conf"

View file

@ -1,8 +1,10 @@
import time import time
import os
from Db import Db from Db import Db
from Config import config from Config import config
from Plugin import PluginManager from Plugin import PluginManager
from Debug import Debug
@PluginManager.acceptPlugins @PluginManager.acceptPlugins
@ -10,6 +12,13 @@ class ContentDb(Db):
def __init__(self, path): def __init__(self, path):
Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path) Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path)
self.foreign_keys = True self.foreign_keys = True
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.schema = self.getSchema()
self.checkTables() self.checkTables()
self.site_ids = {} self.site_ids = {}