diff --git a/deploy/git_over_cdn/client.py b/deploy/git_over_cdn/client.py index 7a3d8cca6..bebe19906 100644 --- a/deploy/git_over_cdn/client.py +++ b/deploy/git_over_cdn/client.py @@ -215,23 +215,26 @@ class GitOverCdnClient: else: self.git_command('reset', '--hard', f'{self.source}/{self.branch}') - def is_uptodate(self): + def get_status(self): """ Returns: - bool: If repo is up-to-date + str: 'uptodate' if repo is up-to-date + 'behind' if repos is not up-to-date + 'failed' if failed """ _ = self.current_commit _ = self.latest_commit if not self.current_commit: self.logger.error('Failed to get current commit') - return False + return 'failed' if not self.latest_commit: self.logger.error('Failed to get latest commit') - return False + return 'failed' if self.current_commit == self.latest_commit: self.logger.info('Already up to date') - return True - return False + return 'uptodate' + self.logger.info('Current repo is behind remote') + return 'behind' def update(self, keep_changes=False): """ diff --git a/module/webui/updater.py b/module/webui/updater.py index b9841f9a7..5c60b2427 100644 --- a/module/webui/updater.py +++ b/module/webui/updater.py @@ -70,12 +70,16 @@ class Updater(DeployConfig, GitManager, PipManager): self.state = "checking" if State.deploy_config.GitOverCdn: - if self.goc_client.is_uptodate(): + status = self.goc_client.get_status() + if status == "uptodate": logger.info(f"No update") return False - else: + elif status == "behind": logger.info(f"New update available") return True + else: + # failed, should fallback to `git pull` + pass source = "origin" for _ in range(3):