mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 01:49:41 +00:00
Fix: [ALAS] Update check fallback to classic git pull if git-over-cdn fails
This commit is contained in:
parent
c74c8729f0
commit
77c394fe18
@ -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):
|
||||
"""
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user