raise error if database is newer
This commit is contained in:
parent
5d45345398
commit
3c7eec9456
2 changed files with 8 additions and 5 deletions
|
@ -981,10 +981,10 @@ class Daemon(jsonrpc.JSONRPC):
|
||||||
self.startup_status = STARTUP_STAGES[1]
|
self.startup_status = STARTUP_STAGES[1]
|
||||||
log.info("Loading databases...")
|
log.info("Loading databases...")
|
||||||
if self.created_data_dir:
|
if self.created_data_dir:
|
||||||
db_revision = open(os.path.join(self.db_dir, "db_revision"), mode='w')
|
db_revision_path = os.path.join(self.db_dir, "db_revision")
|
||||||
db_revision.write(str(self.current_db_revision))
|
with open(db_revision_path, mode='w') as db_revision:
|
||||||
db_revision.close()
|
db_revision.write(str(self.current_db_revision))
|
||||||
log.debug("Created the db revision file: %s", str(os.path.join(self.db_dir, "db_revision")))
|
log.debug("Created the db revision file: %s", db_revision_path)
|
||||||
if not os.path.exists(self.blobfile_dir):
|
if not os.path.exists(self.blobfile_dir):
|
||||||
os.mkdir(self.blobfile_dir)
|
os.mkdir(self.blobfile_dir)
|
||||||
log.debug("Created the blobfile directory: %s", str(self.blobfile_dir))
|
log.debug("Created the blobfile directory: %s", str(self.blobfile_dir))
|
||||||
|
@ -994,6 +994,8 @@ class Daemon(jsonrpc.JSONRPC):
|
||||||
db_revision_file = os.path.join(self.db_dir, "db_revision")
|
db_revision_file = os.path.join(self.db_dir, "db_revision")
|
||||||
if os.path.exists(db_revision_file):
|
if os.path.exists(db_revision_file):
|
||||||
old_revision = int(open(db_revision_file).read().strip())
|
old_revision = int(open(db_revision_file).read().strip())
|
||||||
|
if old_revision > self.current_db_revision:
|
||||||
|
raise Exception('This version of lbrynet is not compatible with the database')
|
||||||
if old_revision < self.current_db_revision:
|
if old_revision < self.current_db_revision:
|
||||||
from lbrynet.db_migrator import dbmigrator
|
from lbrynet.db_migrator import dbmigrator
|
||||||
log.info("Upgrading your databases...")
|
log.info("Upgrading your databases...")
|
||||||
|
|
|
@ -30,7 +30,8 @@ class DaemonServer(object):
|
||||||
self.root.putChild(API_ADDRESS, self._api)
|
self.root.putChild(API_ADDRESS, self._api)
|
||||||
return defer.succeed(True)
|
return defer.succeed(True)
|
||||||
|
|
||||||
def start(self, branch=DEFAULT_UI_BRANCH, user_specified=False, branch_specified=False, wallet=None):
|
def start(self, branch=DEFAULT_UI_BRANCH, user_specified=False,
|
||||||
|
branch_specified=False, wallet=None):
|
||||||
d = self._setup_server(wallet)
|
d = self._setup_server(wallet)
|
||||||
d.addCallback(lambda _: self._api.setup(branch, user_specified, branch_specified))
|
d.addCallback(lambda _: self._api.setup(branch, user_specified, branch_specified))
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Reference in a new issue