Skip to content

Commit

Permalink
fix for config disable
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 27, 2023
1 parent 435a0bd commit b4d1ccf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion music_assistant/common/models/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def update(self, update: dict[str, ConfigValueType]) -> set[str]:
changed_keys.add(key)

# config entry values
for key, new_val in update.items():
values = update.get("values", update)
for key, new_val in values.items():
if key in root_values:
continue
cur_val = self.values[key].value if key in self.values else None
Expand Down
16 changes: 12 additions & 4 deletions music_assistant/server/controllers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,16 @@ async def remove_provider_config(self, instance_id: str) -> None:
if not existing:
raise KeyError(f"Provider {instance_id} does not exist")
prov_manifest = self.mass.get_provider_manifest(existing["domain"])
if prov_manifest.load_by_default:
raise RuntimeError("Default provider can not be removed, use disable instead.")
if prov_manifest.load_by_default and instance_id == prov_manifest.domain:
# Guard for a provider that is loaded by default
LOGGER.warning(
"Provider %s can not be removed, disabling instead...", prov_manifest.name
)
existing["enabled"] = False
await self._update_provider_config(instance_id, existing)
return
if prov_manifest.builtin:
raise RuntimeError("Builtin provider can not be removed.")
raise RuntimeError(f"Builtin provider {prov_manifest.name} can not be removed.")
self.remove(conf_key)
await self.mass.unload_provider(instance_id)
if existing["type"] == "music":
Expand Down Expand Up @@ -640,7 +646,9 @@ async def _update_provider_config(
await self.mass.unload_provider(config.instance_id)
if config.type == ProviderType.PLAYER:
# cleanup entries in player manager
for player in self.mass.players:
for player in self.mass.players.all(
return_unavailable=True, return_hidden=True, return_disabled=True
):
if player.provider != instance_id:
continue
self.mass.players.remove(player.player_id, cleanup_config=False)
Expand Down

0 comments on commit b4d1ccf

Please sign in to comment.