From 8e714072c22e40729edef6799ec79c52f18bd803 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 29 Apr 2025 16:13:56 +0200 Subject: [PATCH] Avoid reading add-ons twice unnecessarily (#5846) So far a store reload lead to a reload of all add-ons twice, usually causing two messages in quick succession: ``` 2025-04-25 17:01:05.058 INFO (MainThread) [supervisor.store] Loading add-ons from store: 91 all - 0 new - 0 remove 2025-04-25 17:01:05.058 INFO (MainThread) [supervisor.store] Loading add-ons from store: 91 all - 0 new - 0 remove ``` This is because when repository changes are detected, `reload()` calls `load()` which then calls `update_repositories()` which ends up calling `_read_addons()`, while `reload()` itself calls `_read_addons()` after `load()` as well. One way to fix this would be to simply remove the `_read_addons()` call in `reload()`. However, it seems the `update_repositories()` call (via `load()`) is not necessary at all, as we don't add new store repositories in `reload()`, and we already made sure the built-ins are present on startup. So simply call `data.update()` to update the store data cache, as it was the case before #2225. There is no apparent reason documented why `data.update()` was changed to a `load()` call. It might be to ensure regularly that built-in repositories are still in the list of store repositories. But this type of regular invariant check is often harmful as it might hide bugs in other places. Supervisor will still call `update_repositories()` in `load()` to ensure all built-in repositories are present, just in case the local configuration file got modified or corrupted. --- supervisor/store/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/store/__init__.py b/supervisor/store/__init__.py index 09aadc737..4f13f7859 100644 --- a/supervisor/store/__init__.py +++ b/supervisor/store/__init__.py @@ -116,7 +116,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration): ) # read data from repositories - await self.load() + await self.data.update() await self._read_addons() @Job(