From: david-sarah Date: Wed, 3 Aug 2011 01:32:12 +0000 (-0700) Subject: Fix the bug that prevents an introducer from starting when introducer.furl already... X-Git-Url: https://git.rkrishnan.org/vdrive/index.php?a=commitdiff_plain;h=2d16a16ee3d99482aba925ce54ab4d9dffe1bcf6;p=tahoe-lafs%2Ftahoe-lafs.git Fix the bug that prevents an introducer from starting when introducer.furl already exists. Also remove some dead code that used to read old config files, and rename 'warn_about_old_config_files' to reflect that it's not a warning. refs #1385 --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index fb7e0c89..ac3b2e00 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -165,22 +165,6 @@ class Client(node.Node, pollmixin.PollMixin): if webport: self.init_web(webport) # strports string - def read_old_config_files(self): - node.Node.read_old_config_files(self) - copy = self._copy_config_from_file - copy("introducer.furl", "client", "introducer.furl") - copy("helper.furl", "client", "helper.furl") - copy("key_generator.furl", "client", "key_generator.furl") - copy("stats_gatherer.furl", "client", "stats_gatherer.furl") - if os.path.exists(os.path.join(self.basedir, "no_storage")): - self.set_config("storage", "enabled", "false") - if os.path.exists(os.path.join(self.basedir, "readonly_storage")): - self.set_config("storage", "readonly", "true") - if os.path.exists(os.path.join(self.basedir, "debug_discard_storage")): - self.set_config("storage", "debug_discard", "true") - if os.path.exists(os.path.join(self.basedir, "run_helper")): - self.set_config("helper", "enabled", "true") - def init_introducer_client(self): self.introducer_furl = self.get_config("client", "introducer.furl") ic = IntroducerClient(self.tub, self.introducer_furl, diff --git a/src/allmydata/introducer/server.py b/src/allmydata/introducer/server.py index 117fcb55..dd042a4f 100644 --- a/src/allmydata/introducer/server.py +++ b/src/allmydata/introducer/server.py @@ -13,6 +13,7 @@ from allmydata.introducer.interfaces import \ class IntroducerNode(node.Node): PORTNUMFILE = "introducer.port" NODETYPE = "introducer" + GENERATED_FILES = ['introducer.furl'] def __init__(self, basedir="."): node.Node.__init__(self, basedir) diff --git a/src/allmydata/node.py b/src/allmydata/node.py index fc7933c0..a671d1df 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -53,6 +53,7 @@ class Node(service.MultiService): NODETYPE = "unknown NODETYPE" PORTNUMFILE = None CERTFILE = "node.pem" + GENERATED_FILES = [] def __init__(self, basedir=u"."): service.MultiService.__init__(self) @@ -62,7 +63,7 @@ class Node(service.MultiService): fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700) open(os.path.join(self.basedir, "private", "README"), "w").write(PRIV_README) - # creates self.config, populates from distinct files if necessary + # creates self.config self.read_config() nickname_utf8 = self.get_config("node", "nickname", "") self.nickname = nickname_utf8.decode("utf-8") @@ -110,11 +111,11 @@ class Node(service.MultiService): assert self.config.get(section, option) == value def read_config(self): - self.warn_about_old_config_files() + self.error_about_old_config_files() self.config = ConfigParser.SafeConfigParser() self.config.read([os.path.join(self.basedir, "tahoe.cfg")]) - def warn_about_old_config_files(self): + def error_about_old_config_files(self): """ If any old configuration files are detected, raise OldConfigError. """ oldfnames = set() @@ -124,10 +125,11 @@ class Node(service.MultiService): 'helper.furl', 'key_generator.furl', 'stats_gatherer.furl', 'no_storage', 'readonly_storage', 'sizelimit', 'debug_discard_storage', 'run_helper']: - fullfname = os.path.join(self.basedir, name) - if os.path.exists(fullfname): - log.err("Found pre-Tahoe-LAFS-v1.3 configuration file: '%s'. See docs/historical/configuration.rst." % (fullfname,)) - oldfnames.add(fullfname) + if name not in self.GENERATED_FILES: + fullfname = os.path.join(self.basedir, name) + if os.path.exists(fullfname): + log.err("Found pre-Tahoe-LAFS-v1.3 configuration file: '%s'. See docs/historical/configuration.rst." % (fullfname,)) + oldfnames.add(fullfname) if oldfnames: raise OldConfigError(oldfnames)