mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Guard writing automation/scene/script config (#31568)
This commit is contained in:
parent
992484fbe6
commit
966df6a411
@ -94,6 +94,7 @@ class BaseEditConfigView(HomeAssistantView):
|
|||||||
self.data_schema = data_schema
|
self.data_schema = data_schema
|
||||||
self.post_write_hook = post_write_hook
|
self.post_write_hook = post_write_hook
|
||||||
self.data_validator = data_validator
|
self.data_validator = data_validator
|
||||||
|
self.mutation_lock = asyncio.Lock()
|
||||||
|
|
||||||
def _empty_config(self):
|
def _empty_config(self):
|
||||||
"""Empty config if file not found."""
|
"""Empty config if file not found."""
|
||||||
@ -114,6 +115,7 @@ class BaseEditConfigView(HomeAssistantView):
|
|||||||
async def get(self, request, config_key):
|
async def get(self, request, config_key):
|
||||||
"""Fetch device specific config."""
|
"""Fetch device specific config."""
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
|
async with self.mutation_lock:
|
||||||
current = await self.read_config(hass)
|
current = await self.read_config(hass)
|
||||||
value = self._get_value(hass, current, config_key)
|
value = self._get_value(hass, current, config_key)
|
||||||
|
|
||||||
@ -148,6 +150,7 @@ class BaseEditConfigView(HomeAssistantView):
|
|||||||
|
|
||||||
path = hass.config.path(self.path)
|
path = hass.config.path(self.path)
|
||||||
|
|
||||||
|
async with self.mutation_lock:
|
||||||
current = await self.read_config(hass)
|
current = await self.read_config(hass)
|
||||||
self._write_value(hass, current, config_key, data)
|
self._write_value(hass, current, config_key, data)
|
||||||
|
|
||||||
@ -163,6 +166,7 @@ class BaseEditConfigView(HomeAssistantView):
|
|||||||
async def delete(self, request, config_key):
|
async def delete(self, request, config_key):
|
||||||
"""Remove an entry."""
|
"""Remove an entry."""
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
|
async with self.mutation_lock:
|
||||||
current = await self.read_config(hass)
|
current = await self.read_config(hass)
|
||||||
value = self._get_value(hass, current, config_key)
|
value = self._get_value(hass, current, config_key)
|
||||||
path = hass.config.path(self.path)
|
path = hass.config.path(self.path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user