Get the path manipulation into _Config too

This commit is contained in:
Jean-Paul Calderone 2020-11-14 09:26:07 -05:00
parent bef5ccd0ca
commit e0f69dcfcf
2 changed files with 15 additions and 7 deletions

View File

@ -465,17 +465,16 @@ def create_introducer_clients(config, main_tub, _introducer_factory=None):
introducers = config.get_introducer_configuration() introducers = config.get_introducer_configuration()
for petname, introducer_furl in introducers.items(): for petname, (furl, cache_path) in introducers.items():
introducer_cache_filepath = FilePath(config.get_private_path("introducer_{}_cache.yaml".format(petname)))
ic = _introducer_factory( ic = _introducer_factory(
main_tub, main_tub,
introducer_furl.encode("ascii"), furl.encode("ascii"),
config.nickname, config.nickname,
str(allmydata.__full_version__), str(allmydata.__full_version__),
str(_Client.OLDEST_SUPPORTED_VERSION), str(_Client.OLDEST_SUPPORTED_VERSION),
list(node.get_app_versions()), list(node.get_app_versions()),
partial(_sequencer, config), partial(_sequencer, config),
introducer_cache_filepath, cache_path,
) )
introducer_clients.append(ic) introducer_clients.append(ic)
return introducer_clients return introducer_clients

View File

@ -438,12 +438,17 @@ class _Config(object):
""" """
Get configuration for introducers. Get configuration for introducers.
:return {unicode: unicode}: A mapping from introducer petname to the :return {unicode: (unicode, FilePath)}: A mapping from introducer
introducer's fURL. petname to a tuple of the introducer's fURL and local cache path.
""" """
introducers_yaml_filename = self.get_private_path("introducers.yaml") introducers_yaml_filename = self.get_private_path("introducers.yaml")
introducers_filepath = FilePath(introducers_yaml_filename) introducers_filepath = FilePath(introducers_yaml_filename)
def get_cache_filepath(petname):
return FilePath(
self.get_private_path("introducer_{}_cache.yaml".format(petname)),
)
try: try:
with introducers_filepath.open() as f: with introducers_filepath.open() as f:
introducers_yaml = safe_load(f) introducers_yaml = safe_load(f)
@ -491,7 +496,11 @@ class _Config(object):
) )
introducers['default'] = tahoe_cfg_introducer_furl introducers['default'] = tahoe_cfg_introducer_furl
return introducers return {
petname: (furl, get_cache_filepath(petname))
for (petname, furl)
in introducers.items()
}
def create_tub_options(config): def create_tub_options(config):