From 26024053ede93f96d8b9ee1d1f9d3bfb7634d081 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 4 Mar 2025 21:09:46 +0100 Subject: [PATCH] Fix add-on store repository getting removed without internet (#5717) * Fix add-on store repository getting removed without internet Currently, when a git command error happens in `pull()`, we declare the repository as corrupt. Subsequent system autofix runs then execute the reset resolution, which essentially removes the git repository from the system. In situations where the Internet fails right between the last Supervisor connectivity check and the add-on store repository update (the connectivity checks are throttled to once every 10 minutes while connectivity is considered good), or if the outage is only partial (e.g. reaching connectivity check works but the store repository is not reachable), this leads to a git command error which declares the repository as corrupt just as well, and ultimately leads to the removal of the add-on store repository from the local system. Run a git ls-remote first, which is used as an extra connectivity check. This will also avoid removing the repository if Internet connectivity works but the git provider is temporary down or not reachable. That said, it will also fail if the repository is no longer present. But this case needs extra handling anyways. * Run git ls-remote in executor --- supervisor/store/git.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/supervisor/store/git.py b/supervisor/store/git.py index 2c2b86aaf..6841e6823 100644 --- a/supervisor/store/git.py +++ b/supervisor/store/git.py @@ -132,6 +132,13 @@ class GitRepo(CoreSysAttributes): async with self.lock: _LOGGER.info("Update add-on %s repository from %s", self.path, self.url) + try: + git_cmd = git.Git() + await self.sys_run_in_executor(git_cmd.ls_remote, "--heads", self.url) + except git.CommandError as err: + _LOGGER.warning("Wasn't able to update %s repo: %s.", self.url, err) + raise StoreGitError() from err + try: branch = self.repo.active_branch.name