forked from LBRYCommunity/lbry-sdk
Refactor how adjustable settings are pulled out of config.settings
- Factor out this functionality into separate method - Change the set_settings() JSON-RPC method to use this (before, it was just returning all fields, which doesn't work anymore after the settings refactor)
This commit is contained in:
parent
ef8d1cfdc2
commit
205a10bc8e
2 changed files with 7 additions and 3 deletions
|
@ -270,6 +270,9 @@ class Config(DefaultSettings):
|
|||
def UI_ADDRESS(self):
|
||||
return "http://%s:%i" % (DEFAULT_SETTINGS.API_INTERFACE, self.api_port)
|
||||
|
||||
def get_adjustable_settings_dict(self):
|
||||
return {opt: val for opt, val in self.get_dict().iteritems() if opt in ENVIRONMENT.original_schema}
|
||||
|
||||
def ensure_data_dir(self):
|
||||
# although there is a risk of a race condition here we don't
|
||||
# expect there to be multiple processes accessing this
|
||||
|
@ -337,7 +340,8 @@ def load_settings(path):
|
|||
# or command line flag we don't want to persist it for future settings.
|
||||
def save_settings(path=None):
|
||||
path = path or settings.get_conf_filename()
|
||||
to_save = {k: v for k, v in settings.__dict__.iteritems() if k in ADJUSTABLE_SETTINGS}
|
||||
to_save = settings.get_adjustable_settings_dict()
|
||||
|
||||
ext = os.path.splitext(path)[1]
|
||||
encoder = settings_encoders.get(ext, False)
|
||||
assert encoder is not False, "Unknown settings format .%s" % ext
|
||||
|
|
|
@ -1255,12 +1255,12 @@ class Daemon(AuthJSONRPCServer):
|
|||
"""
|
||||
|
||||
def _log_settings_change():
|
||||
log.info("Set daemon settings to " + json.dumps(conf.settings.configurable_settings))
|
||||
log.info("Set daemon settings to " + json.dumps(conf.settings.get_adjustable_settings_dict()))
|
||||
|
||||
d = self._update_settings(p)
|
||||
d.addErrback(lambda err: log.info(err.getTraceback()))
|
||||
d.addCallback(lambda _: _log_settings_change())
|
||||
d.addCallback(lambda _: self._render_response(conf.settings.configurable_settings, OK_CODE))
|
||||
d.addCallback(lambda _: self._render_response(conf.settings.get_adjustable_settings_dict(), OK_CODE))
|
||||
|
||||
return d
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue