From 1acb00e2f1d6d8d49c9bb50f7456ed59e810f424 Mon Sep 17 00:00:00 2001 From: Arksine Date: Tue, 29 Dec 2020 20:05:11 -0500 Subject: [PATCH] update_manager: only fetch the git remote when necessary After a repo has been updated fetching the remote is not needed, as it was just done in the prior update step. Signed-off-by: Eric Callahan --- moonraker/plugins/update_manager.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/moonraker/plugins/update_manager.py b/moonraker/plugins/update_manager.py index 849fed6..20194b9 100644 --- a/moonraker/plugins/update_manager.py +++ b/moonraker/plugins/update_manager.py @@ -347,7 +347,7 @@ class GitUpdater: await self._check_version() self.init_evt.set() - async def _check_version(self): + async def _check_version(self, need_fetch=True): self.is_valid = self.detached = False self.cur_hash = self.branch = self.remote = "?" self.version = self.remote_version = "?" @@ -377,9 +377,10 @@ class GitUpdater: self.remote = await self.execute_cmd_with_response( f"git -C {self.repo_path} config --get" f" branch.{self.branch}.remote") - await self.execute_cmd( - f"git -C {self.repo_path} fetch {self.remote} --prune -q", - retries=3) + if need_fetch: + await self.execute_cmd( + f"git -C {self.repo_path} fetch {self.remote} --prune -q", + retries=3) remote_url = await self.execute_cmd_with_response( f"git -C {self.repo_path} remote get-url {self.remote}") cur_hash = await self.execute_cmd_with_response( @@ -469,7 +470,7 @@ class GitUpdater: elif need_env_rebuild: await self._update_virtualenv(True) # Refresh local repo state - await self._check_version() + await self._check_version(need_fetch=False) if self.name == "moonraker": # Launch restart async so the request can return # before the server restarts