From ece29b1a6581d36bbd8922dd492fb56b543c8b48 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 16 Aug 2024 18:13:12 +0200 Subject: [PATCH] fix load race in config --- music_assistant/server/controllers/config.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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: -- 2.34.1