Skip to content

Commit

Permalink
fix remote config reload (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
emphasize authored Sep 18, 2023
1 parent 1b04180 commit 8232d00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ovos_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
MycroftSystemConfig, MycroftUserConfig, RemoteConf
from ovos_config.locations import OLD_USER_CONFIG, get_xdg_config_save_path, \
get_xdg_config_locations
from ovos_config.utils import FileWatcher
from ovos_utils.file_utils import FileWatcher

from ovos_utils.json_helper import flattened_delete, merge_dict
from ovos_utils.log import LOG
Expand Down
15 changes: 10 additions & 5 deletions ovos_config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __init__(self, allow_overwrite=False):


class RemoteConf(LocalConf):
"""Config dictionary fetched from mycroft.ai."""
"""Config dictionary fetched from the backend"""

def __init__(self, cache=WEB_CONFIG_CACHE):
super(RemoteConf, self).__init__(cache)
Expand All @@ -204,12 +204,17 @@ def reload(self):
return

remote = RemoteConfigManager()

remote.download()

changed = []
for key in remote.config:
self.__setitem__(key, remote.config[key])
LOG.debug(f"writing remote config to {self.path}")
self.store(self.path)
if self.get(key) != remote.config[key]:
changed.append(key)
self.__setitem__(key, remote.config[key])

if changed:
LOG.debug(f"config key(s) {changed} changed, writing remote config to {self.path}")
self.store(self.path)

except Exception as e:
LOG.error(f"Exception fetching remote configuration: {e}")
Expand Down

0 comments on commit 8232d00

Please sign in to comment.