mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 23:26:29 +00:00
Use await for all FileConfiguration calls (#5683)
Some calls got missed in PR #5652. Update all calls to await the save_data() coroutine.
This commit is contained in:
parent
ddee79d209
commit
39f5b91f12
@ -852,7 +852,7 @@ class Addon(AddonModel):
|
|||||||
for service in self.sys_services.list_services:
|
for service in self.sys_services.list_services:
|
||||||
if self.slug not in service.active:
|
if self.slug not in service.active:
|
||||||
continue
|
continue
|
||||||
service.del_service_data(self)
|
await service.del_service_data(self)
|
||||||
|
|
||||||
# Remove from addon manager
|
# Remove from addon manager
|
||||||
await self.sys_addons.data.uninstall(self)
|
await self.sys_addons.data.uninstall(self)
|
||||||
|
@ -212,7 +212,7 @@ class APIBackups(CoreSysAttributes):
|
|||||||
if ATTR_DAYS_UNTIL_STALE in body:
|
if ATTR_DAYS_UNTIL_STALE in body:
|
||||||
self.sys_backups.days_until_stale = body[ATTR_DAYS_UNTIL_STALE]
|
self.sys_backups.days_until_stale = body[ATTR_DAYS_UNTIL_STALE]
|
||||||
|
|
||||||
self.sys_backups.save_data()
|
await self.sys_backups.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def reload(self, _):
|
async def reload(self, _):
|
||||||
|
@ -78,7 +78,7 @@ class APICoreDNS(CoreSysAttributes):
|
|||||||
if restart_required:
|
if restart_required:
|
||||||
self.sys_create_task(self.sys_plugins.dns.restart())
|
self.sys_create_task(self.sys_plugins.dns.restart())
|
||||||
|
|
||||||
self.sys_plugins.dns.save_data()
|
await self.sys_plugins.dns.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def stats(self, request: web.Request) -> dict[str, Any]:
|
async def stats(self, request: web.Request) -> dict[str, Any]:
|
||||||
|
@ -53,7 +53,7 @@ class APIDocker(CoreSysAttributes):
|
|||||||
for hostname, registry in body.items():
|
for hostname, registry in body.items():
|
||||||
self.sys_docker.config.registries[hostname] = registry
|
self.sys_docker.config.registries[hostname] = registry
|
||||||
|
|
||||||
self.sys_docker.config.save_data()
|
await self.sys_docker.config.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def remove_registry(self, request: web.Request):
|
async def remove_registry(self, request: web.Request):
|
||||||
@ -63,7 +63,7 @@ class APIDocker(CoreSysAttributes):
|
|||||||
raise APINotFound(f"Hostname {hostname} does not exist in registries")
|
raise APINotFound(f"Hostname {hostname} does not exist in registries")
|
||||||
|
|
||||||
del self.sys_docker.config.registries[hostname]
|
del self.sys_docker.config.registries[hostname]
|
||||||
self.sys_docker.config.save_data()
|
await self.sys_docker.config.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def info(self, request: web.Request):
|
async def info(self, request: web.Request):
|
||||||
|
@ -149,7 +149,7 @@ class APIHomeAssistant(CoreSysAttributes):
|
|||||||
ATTR_BACKUPS_EXCLUDE_DATABASE
|
ATTR_BACKUPS_EXCLUDE_DATABASE
|
||||||
]
|
]
|
||||||
|
|
||||||
self.sys_homeassistant.save_data()
|
await self.sys_homeassistant.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def stats(self, request: web.Request) -> dict[Any, str]:
|
async def stats(self, request: web.Request) -> dict[Any, str]:
|
||||||
|
@ -92,7 +92,7 @@ class APIJobs(CoreSysAttributes):
|
|||||||
if ATTR_IGNORE_CONDITIONS in body:
|
if ATTR_IGNORE_CONDITIONS in body:
|
||||||
self.sys_jobs.ignore_conditions = body[ATTR_IGNORE_CONDITIONS]
|
self.sys_jobs.ignore_conditions = body[ATTR_IGNORE_CONDITIONS]
|
||||||
|
|
||||||
self.sys_jobs.save_data()
|
await self.sys_jobs.save_data()
|
||||||
|
|
||||||
await self.sys_resolution.evaluate.evaluate_system()
|
await self.sys_resolution.evaluate.evaluate_system()
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class APIMounts(CoreSysAttributes):
|
|||||||
else:
|
else:
|
||||||
self.sys_mounts.default_backup_mount = mount
|
self.sys_mounts.default_backup_mount = mount
|
||||||
|
|
||||||
self.sys_mounts.save_data()
|
await self.sys_mounts.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def create_mount(self, request: web.Request) -> None:
|
async def create_mount(self, request: web.Request) -> None:
|
||||||
@ -87,7 +87,7 @@ class APIMounts(CoreSysAttributes):
|
|||||||
if not self.sys_mounts.default_backup_mount:
|
if not self.sys_mounts.default_backup_mount:
|
||||||
self.sys_mounts.default_backup_mount = mount
|
self.sys_mounts.default_backup_mount = mount
|
||||||
|
|
||||||
self.sys_mounts.save_data()
|
await self.sys_mounts.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def update_mount(self, request: web.Request) -> None:
|
async def update_mount(self, request: web.Request) -> None:
|
||||||
@ -110,7 +110,7 @@ class APIMounts(CoreSysAttributes):
|
|||||||
elif self.sys_mounts.default_backup_mount == mount:
|
elif self.sys_mounts.default_backup_mount == mount:
|
||||||
self.sys_mounts.default_backup_mount = None
|
self.sys_mounts.default_backup_mount = None
|
||||||
|
|
||||||
self.sys_mounts.save_data()
|
await self.sys_mounts.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def delete_mount(self, request: web.Request) -> None:
|
async def delete_mount(self, request: web.Request) -> None:
|
||||||
@ -122,7 +122,7 @@ class APIMounts(CoreSysAttributes):
|
|||||||
if mount.usage == MountUsage.BACKUP:
|
if mount.usage == MountUsage.BACKUP:
|
||||||
self.sys_create_task(self.sys_backups.reload())
|
self.sys_create_task(self.sys_backups.reload())
|
||||||
|
|
||||||
self.sys_mounts.save_data()
|
await self.sys_mounts.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def reload_mount(self, request: web.Request) -> None:
|
async def reload_mount(self, request: web.Request) -> None:
|
||||||
|
@ -169,7 +169,7 @@ class APIOS(CoreSysAttributes):
|
|||||||
body[ATTR_SYSTEM_HEALTH_LED]
|
body[ATTR_SYSTEM_HEALTH_LED]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.sys_dbus.agent.board.green.save_data()
|
await self.sys_dbus.agent.board.green.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def boards_yellow_info(self, request: web.Request) -> dict[str, Any]:
|
async def boards_yellow_info(self, request: web.Request) -> dict[str, Any]:
|
||||||
@ -196,7 +196,7 @@ class APIOS(CoreSysAttributes):
|
|||||||
if ATTR_POWER_LED in body:
|
if ATTR_POWER_LED in body:
|
||||||
await self.sys_dbus.agent.board.yellow.set_power_led(body[ATTR_POWER_LED])
|
await self.sys_dbus.agent.board.yellow.set_power_led(body[ATTR_POWER_LED])
|
||||||
|
|
||||||
self.sys_dbus.agent.board.yellow.save_data()
|
await self.sys_dbus.agent.board.yellow.save_data()
|
||||||
self.sys_resolution.create_issue(
|
self.sys_resolution.create_issue(
|
||||||
IssueType.REBOOT_REQUIRED,
|
IssueType.REBOOT_REQUIRED,
|
||||||
ContextType.SYSTEM,
|
ContextType.SYSTEM,
|
||||||
|
@ -126,7 +126,7 @@ class APIResoulution(CoreSysAttributes):
|
|||||||
if ATTR_ENABLED in body:
|
if ATTR_ENABLED in body:
|
||||||
check.enabled = body[ATTR_ENABLED]
|
check.enabled = body[ATTR_ENABLED]
|
||||||
|
|
||||||
self.sys_resolution.save_data()
|
await self.sys_resolution.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def run_check(self, request: web.Request) -> None:
|
async def run_check(self, request: web.Request) -> None:
|
||||||
|
@ -48,7 +48,7 @@ class APISecurity(CoreSysAttributes):
|
|||||||
if ATTR_FORCE_SECURITY in body:
|
if ATTR_FORCE_SECURITY in body:
|
||||||
self.sys_security.force = body[ATTR_FORCE_SECURITY]
|
self.sys_security.force = body[ATTR_FORCE_SECURITY]
|
||||||
|
|
||||||
self.sys_security.save_data()
|
await self.sys_security.save_data()
|
||||||
|
|
||||||
await self.sys_resolution.evaluate.evaluate_system()
|
await self.sys_resolution.evaluate.evaluate_system()
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class APIServices(CoreSysAttributes):
|
|||||||
addon = request[REQUEST_FROM]
|
addon = request[REQUEST_FROM]
|
||||||
|
|
||||||
_check_access(request, service.slug)
|
_check_access(request, service.slug)
|
||||||
service.set_service_data(addon, body)
|
await service.set_service_data(addon, body)
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def get_service(self, request):
|
async def get_service(self, request):
|
||||||
@ -69,7 +69,7 @@ class APIServices(CoreSysAttributes):
|
|||||||
|
|
||||||
# Access
|
# Access
|
||||||
_check_access(request, service.slug, True)
|
_check_access(request, service.slug, True)
|
||||||
service.del_service_data(addon)
|
await service.del_service_data(addon)
|
||||||
|
|
||||||
|
|
||||||
def _check_access(request, service, provide=False):
|
def _check_access(request, service, provide=False):
|
||||||
|
@ -159,8 +159,8 @@ class APISupervisor(CoreSysAttributes):
|
|||||||
self.sys_config.wait_boot = body[ATTR_WAIT_BOOT]
|
self.sys_config.wait_boot = body[ATTR_WAIT_BOOT]
|
||||||
|
|
||||||
# Save changes before processing addons in case of errors
|
# Save changes before processing addons in case of errors
|
||||||
self.sys_updater.save_data()
|
await self.sys_updater.save_data()
|
||||||
self.sys_config.save_data()
|
await self.sys_config.save_data()
|
||||||
|
|
||||||
# Remove: 2022.9
|
# Remove: 2022.9
|
||||||
if ATTR_ADDONS_REPOSITORIES in body:
|
if ATTR_ADDONS_REPOSITORIES in body:
|
||||||
|
@ -25,7 +25,7 @@ class FixupMountExecuteRemove(FixupBase):
|
|||||||
except MountNotFound:
|
except MountNotFound:
|
||||||
_LOGGER.warning("Can't find mount %s for fixup", reference)
|
_LOGGER.warning("Can't find mount %s for fixup", reference)
|
||||||
else:
|
else:
|
||||||
self.sys_mounts.save_data()
|
await self.sys_mounts.save_data()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def suggestion(self) -> SuggestionType:
|
def suggestion(self) -> SuggestionType:
|
||||||
|
@ -51,9 +51,9 @@ class ServiceInterface(CoreSysAttributes, ABC):
|
|||||||
"""Return True if the service is in use."""
|
"""Return True if the service is in use."""
|
||||||
return bool(self._data)
|
return bool(self._data)
|
||||||
|
|
||||||
def save(self) -> None:
|
async def save(self) -> None:
|
||||||
"""Save changes."""
|
"""Save changes."""
|
||||||
self.sys_services.data.save_data()
|
await self.sys_services.data.save_data()
|
||||||
|
|
||||||
def get_service_data(self) -> dict[str, Any] | None:
|
def get_service_data(self) -> dict[str, Any] | None:
|
||||||
"""Return the requested service data."""
|
"""Return the requested service data."""
|
||||||
@ -62,9 +62,9 @@ class ServiceInterface(CoreSysAttributes, ABC):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def set_service_data(self, addon: Addon, data: dict[str, Any]) -> None:
|
async def set_service_data(self, addon: Addon, data: dict[str, Any]) -> None:
|
||||||
"""Write the data into service object."""
|
"""Write the data into service object."""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def del_service_data(self, addon: Addon) -> None:
|
async def del_service_data(self, addon: Addon) -> None:
|
||||||
"""Remove the data from service object."""
|
"""Remove the data from service object."""
|
||||||
|
@ -65,7 +65,7 @@ class MQTTService(ServiceInterface):
|
|||||||
return []
|
return []
|
||||||
return [self._data[ATTR_ADDON]]
|
return [self._data[ATTR_ADDON]]
|
||||||
|
|
||||||
def set_service_data(self, addon: Addon, data: dict[str, Any]) -> None:
|
async def set_service_data(self, addon: Addon, data: dict[str, Any]) -> None:
|
||||||
"""Write the data into service object."""
|
"""Write the data into service object."""
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
raise ServicesError(
|
raise ServicesError(
|
||||||
@ -77,9 +77,9 @@ class MQTTService(ServiceInterface):
|
|||||||
self._data[ATTR_ADDON] = addon.slug
|
self._data[ATTR_ADDON] = addon.slug
|
||||||
|
|
||||||
_LOGGER.info("Set %s as service provider for mqtt", addon.slug)
|
_LOGGER.info("Set %s as service provider for mqtt", addon.slug)
|
||||||
self.save()
|
await self.save()
|
||||||
|
|
||||||
def del_service_data(self, addon: Addon) -> None:
|
async def del_service_data(self, addon: Addon) -> None:
|
||||||
"""Remove the data from service object."""
|
"""Remove the data from service object."""
|
||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
raise ServicesError(
|
raise ServicesError(
|
||||||
@ -87,4 +87,4 @@ class MQTTService(ServiceInterface):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._data.clear()
|
self._data.clear()
|
||||||
self.save()
|
await self.save()
|
||||||
|
@ -59,7 +59,7 @@ class MySQLService(ServiceInterface):
|
|||||||
return []
|
return []
|
||||||
return [self._data[ATTR_ADDON]]
|
return [self._data[ATTR_ADDON]]
|
||||||
|
|
||||||
def set_service_data(self, addon: Addon, data: dict[str, Any]) -> None:
|
async def set_service_data(self, addon: Addon, data: dict[str, Any]) -> None:
|
||||||
"""Write the data into service object."""
|
"""Write the data into service object."""
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
raise ServicesError(
|
raise ServicesError(
|
||||||
@ -71,12 +71,12 @@ class MySQLService(ServiceInterface):
|
|||||||
self._data[ATTR_ADDON] = addon.slug
|
self._data[ATTR_ADDON] = addon.slug
|
||||||
|
|
||||||
_LOGGER.info("Set %s as service provider for MySQL", addon.slug)
|
_LOGGER.info("Set %s as service provider for MySQL", addon.slug)
|
||||||
self.save()
|
await self.save()
|
||||||
|
|
||||||
def del_service_data(self, addon: Addon) -> None:
|
async def del_service_data(self, addon: Addon) -> None:
|
||||||
"""Remove the data from service object."""
|
"""Remove the data from service object."""
|
||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
raise ServicesError("Can't remove not exists services", _LOGGER.warning)
|
raise ServicesError("Can't remove not exists services", _LOGGER.warning)
|
||||||
|
|
||||||
self._data.clear()
|
self._data.clear()
|
||||||
self.save()
|
await self.save()
|
||||||
|
@ -206,7 +206,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration):
|
|||||||
# On start-up we add the saved repos to force a load. But they're already in data
|
# On start-up we add the saved repos to force a load. But they're already in data
|
||||||
if url not in self._data[ATTR_REPOSITORIES]:
|
if url not in self._data[ATTR_REPOSITORIES]:
|
||||||
self._data[ATTR_REPOSITORIES].append(url)
|
self._data[ATTR_REPOSITORIES].append(url)
|
||||||
self.save_data()
|
await self.save_data()
|
||||||
|
|
||||||
# Persist changes
|
# Persist changes
|
||||||
if persist:
|
if persist:
|
||||||
@ -227,7 +227,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration):
|
|||||||
)
|
)
|
||||||
await self.repositories.pop(repository.slug).remove()
|
await self.repositories.pop(repository.slug).remove()
|
||||||
self._data[ATTR_REPOSITORIES].remove(repository.source)
|
self._data[ATTR_REPOSITORIES].remove(repository.source)
|
||||||
self.save_data()
|
await self.save_data()
|
||||||
|
|
||||||
if persist:
|
if persist:
|
||||||
await self.data.update()
|
await self.data.update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user