From: Marcel van der Veldt Date: Fri, 16 Aug 2024 16:13:12 +0000 (+0200) Subject: fix load race in config X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=ece29b1a6581d36bbd8922dd492fb56b543c8b48;p=music-assistant-server.git fix load race in config --- diff --git a/music_assistant/server/controllers/config.py b/music_assistant/server/controllers/config.py index fac362e0..5a24442c 100644 --- a/music_assistant/server/controllers/config.py +++ b/music_assistant/server/controllers/config.py @@ -820,11 +820,17 @@ class ConfigController: ) # validate the new config config.validate() - # try to load the provider first to catch errors before we save it. - await self.mass.load_provider_config(config) - # the load was a success, store this config + # save the config first to prevent issues when the + # provider wants to manipulate the config during load conf_key = f"{CONF_PROVIDERS}/{config.instance_id}" self.set(conf_key, config.to_raw()) + # try to load the provider + try: + await self._load_provider_config(config) + except Exception: + # loading failed, remove config + self.remove(conf_key) + raise return config async def _load_provider_config(self, config: ProviderConfig) -> None: