diff --git a/supervisor/addons/addon.py b/supervisor/addons/addon.py index b71536039..3a28678d0 100644 --- a/supervisor/addons/addon.py +++ b/supervisor/addons/addon.py @@ -852,7 +852,7 @@ class Addon(AddonModel): for service in self.sys_services.list_services: if self.slug not in service.active: continue - service.del_service_data(self) + await service.del_service_data(self) # Remove from addon manager await self.sys_addons.data.uninstall(self) diff --git a/supervisor/api/backups.py b/supervisor/api/backups.py index 371312950..76c096ff6 100644 --- a/supervisor/api/backups.py +++ b/supervisor/api/backups.py @@ -212,7 +212,7 @@ class APIBackups(CoreSysAttributes): if ATTR_DAYS_UNTIL_STALE in body: self.sys_backups.days_until_stale = body[ATTR_DAYS_UNTIL_STALE] - self.sys_backups.save_data() + await self.sys_backups.save_data() @api_process async def reload(self, _): diff --git a/supervisor/api/dns.py b/supervisor/api/dns.py index 4aa990228..63fef6d53 100644 --- a/supervisor/api/dns.py +++ b/supervisor/api/dns.py @@ -78,7 +78,7 @@ class APICoreDNS(CoreSysAttributes): if restart_required: self.sys_create_task(self.sys_plugins.dns.restart()) - self.sys_plugins.dns.save_data() + await self.sys_plugins.dns.save_data() @api_process async def stats(self, request: web.Request) -> dict[str, Any]: diff --git a/supervisor/api/docker.py b/supervisor/api/docker.py index dfa6c849e..4f410f033 100644 --- a/supervisor/api/docker.py +++ b/supervisor/api/docker.py @@ -53,7 +53,7 @@ class APIDocker(CoreSysAttributes): for hostname, registry in body.items(): self.sys_docker.config.registries[hostname] = registry - self.sys_docker.config.save_data() + await self.sys_docker.config.save_data() @api_process 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") del self.sys_docker.config.registries[hostname] - self.sys_docker.config.save_data() + await self.sys_docker.config.save_data() @api_process async def info(self, request: web.Request): diff --git a/supervisor/api/homeassistant.py b/supervisor/api/homeassistant.py index b68215b4a..add52b49b 100644 --- a/supervisor/api/homeassistant.py +++ b/supervisor/api/homeassistant.py @@ -149,7 +149,7 @@ class APIHomeAssistant(CoreSysAttributes): ATTR_BACKUPS_EXCLUDE_DATABASE ] - self.sys_homeassistant.save_data() + await self.sys_homeassistant.save_data() @api_process async def stats(self, request: web.Request) -> dict[Any, str]: diff --git a/supervisor/api/jobs.py b/supervisor/api/jobs.py index 7ee806813..4c7e5adf7 100644 --- a/supervisor/api/jobs.py +++ b/supervisor/api/jobs.py @@ -92,7 +92,7 @@ class APIJobs(CoreSysAttributes): if ATTR_IGNORE_CONDITIONS in body: 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() diff --git a/supervisor/api/mounts.py b/supervisor/api/mounts.py index 8567580f8..2a4aa99a7 100644 --- a/supervisor/api/mounts.py +++ b/supervisor/api/mounts.py @@ -66,7 +66,7 @@ class APIMounts(CoreSysAttributes): else: self.sys_mounts.default_backup_mount = mount - self.sys_mounts.save_data() + await self.sys_mounts.save_data() @api_process async def create_mount(self, request: web.Request) -> None: @@ -87,7 +87,7 @@ class APIMounts(CoreSysAttributes): if not self.sys_mounts.default_backup_mount: self.sys_mounts.default_backup_mount = mount - self.sys_mounts.save_data() + await self.sys_mounts.save_data() @api_process async def update_mount(self, request: web.Request) -> None: @@ -110,7 +110,7 @@ class APIMounts(CoreSysAttributes): elif self.sys_mounts.default_backup_mount == mount: self.sys_mounts.default_backup_mount = None - self.sys_mounts.save_data() + await self.sys_mounts.save_data() @api_process async def delete_mount(self, request: web.Request) -> None: @@ -122,7 +122,7 @@ class APIMounts(CoreSysAttributes): if mount.usage == MountUsage.BACKUP: self.sys_create_task(self.sys_backups.reload()) - self.sys_mounts.save_data() + await self.sys_mounts.save_data() @api_process async def reload_mount(self, request: web.Request) -> None: diff --git a/supervisor/api/os.py b/supervisor/api/os.py index 28a589cbb..ab6b79f52 100644 --- a/supervisor/api/os.py +++ b/supervisor/api/os.py @@ -169,7 +169,7 @@ class APIOS(CoreSysAttributes): body[ATTR_SYSTEM_HEALTH_LED] ) - self.sys_dbus.agent.board.green.save_data() + await self.sys_dbus.agent.board.green.save_data() @api_process 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: 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( IssueType.REBOOT_REQUIRED, ContextType.SYSTEM, diff --git a/supervisor/api/resolution.py b/supervisor/api/resolution.py index f08971e6f..7387087e1 100644 --- a/supervisor/api/resolution.py +++ b/supervisor/api/resolution.py @@ -126,7 +126,7 @@ class APIResoulution(CoreSysAttributes): if ATTR_ENABLED in body: check.enabled = body[ATTR_ENABLED] - self.sys_resolution.save_data() + await self.sys_resolution.save_data() @api_process async def run_check(self, request: web.Request) -> None: diff --git a/supervisor/api/security.py b/supervisor/api/security.py index d0e416aa8..ebafe62ee 100644 --- a/supervisor/api/security.py +++ b/supervisor/api/security.py @@ -48,7 +48,7 @@ class APISecurity(CoreSysAttributes): if ATTR_FORCE_SECURITY in body: 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() diff --git a/supervisor/api/services.py b/supervisor/api/services.py index 60f61bb15..e61fcc321 100644 --- a/supervisor/api/services.py +++ b/supervisor/api/services.py @@ -47,7 +47,7 @@ class APIServices(CoreSysAttributes): addon = request[REQUEST_FROM] _check_access(request, service.slug) - service.set_service_data(addon, body) + await service.set_service_data(addon, body) @api_process async def get_service(self, request): @@ -69,7 +69,7 @@ class APIServices(CoreSysAttributes): # Access _check_access(request, service.slug, True) - service.del_service_data(addon) + await service.del_service_data(addon) def _check_access(request, service, provide=False): diff --git a/supervisor/api/supervisor.py b/supervisor/api/supervisor.py index bbe5f9184..9b275a21f 100644 --- a/supervisor/api/supervisor.py +++ b/supervisor/api/supervisor.py @@ -159,8 +159,8 @@ class APISupervisor(CoreSysAttributes): self.sys_config.wait_boot = body[ATTR_WAIT_BOOT] # Save changes before processing addons in case of errors - self.sys_updater.save_data() - self.sys_config.save_data() + await self.sys_updater.save_data() + await self.sys_config.save_data() # Remove: 2022.9 if ATTR_ADDONS_REPOSITORIES in body: diff --git a/supervisor/resolution/fixups/mount_execute_remove.py b/supervisor/resolution/fixups/mount_execute_remove.py index 26850ff61..f01b4d4c2 100644 --- a/supervisor/resolution/fixups/mount_execute_remove.py +++ b/supervisor/resolution/fixups/mount_execute_remove.py @@ -25,7 +25,7 @@ class FixupMountExecuteRemove(FixupBase): except MountNotFound: _LOGGER.warning("Can't find mount %s for fixup", reference) else: - self.sys_mounts.save_data() + await self.sys_mounts.save_data() @property def suggestion(self) -> SuggestionType: diff --git a/supervisor/services/interface.py b/supervisor/services/interface.py index 39e12e663..7eba58196 100644 --- a/supervisor/services/interface.py +++ b/supervisor/services/interface.py @@ -51,9 +51,9 @@ class ServiceInterface(CoreSysAttributes, ABC): """Return True if the service is in use.""" return bool(self._data) - def save(self) -> None: + async def save(self) -> None: """Save changes.""" - self.sys_services.data.save_data() + await self.sys_services.data.save_data() def get_service_data(self) -> dict[str, Any] | None: """Return the requested service data.""" @@ -62,9 +62,9 @@ class ServiceInterface(CoreSysAttributes, ABC): return None @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.""" @abstractmethod - def del_service_data(self, addon: Addon) -> None: + async def del_service_data(self, addon: Addon) -> None: """Remove the data from service object.""" diff --git a/supervisor/services/modules/mqtt.py b/supervisor/services/modules/mqtt.py index 398571f24..7927e2218 100644 --- a/supervisor/services/modules/mqtt.py +++ b/supervisor/services/modules/mqtt.py @@ -65,7 +65,7 @@ class MQTTService(ServiceInterface): return [] 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.""" if self.enabled: raise ServicesError( @@ -77,9 +77,9 @@ class MQTTService(ServiceInterface): self._data[ATTR_ADDON] = 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.""" if not self.enabled: raise ServicesError( @@ -87,4 +87,4 @@ class MQTTService(ServiceInterface): ) self._data.clear() - self.save() + await self.save() diff --git a/supervisor/services/modules/mysql.py b/supervisor/services/modules/mysql.py index 3a9f143c2..dfb922196 100644 --- a/supervisor/services/modules/mysql.py +++ b/supervisor/services/modules/mysql.py @@ -59,7 +59,7 @@ class MySQLService(ServiceInterface): return [] 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.""" if self.enabled: raise ServicesError( @@ -71,12 +71,12 @@ class MySQLService(ServiceInterface): self._data[ATTR_ADDON] = 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.""" if not self.enabled: raise ServicesError("Can't remove not exists services", _LOGGER.warning) self._data.clear() - self.save() + await self.save() diff --git a/supervisor/store/__init__.py b/supervisor/store/__init__.py index 5b3db3eaf..787e560d1 100644 --- a/supervisor/store/__init__.py +++ b/supervisor/store/__init__.py @@ -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 if url not in self._data[ATTR_REPOSITORIES]: self._data[ATTR_REPOSITORIES].append(url) - self.save_data() + await self.save_data() # Persist changes if persist: @@ -227,7 +227,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration): ) await self.repositories.pop(repository.slug).remove() self._data[ATTR_REPOSITORIES].remove(repository.source) - self.save_data() + await self.save_data() if persist: await self.data.update()