mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 00:35:34 +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:
|
else:
|
||||||
self.git_command('reset', '--hard', f'{self.source}/{self.branch}')
|
self.git_command('reset', '--hard', f'{self.source}/{self.branch}')
|
||||||
|
|
||||||
def is_uptodate(self):
|
def get_status(self):
|
||||||
"""
|
"""
|
||||||
Returns:
|
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.current_commit
|
||||||
_ = self.latest_commit
|
_ = self.latest_commit
|
||||||
if not self.current_commit:
|
if not self.current_commit:
|
||||||
self.logger.error('Failed to get current commit')
|
self.logger.error('Failed to get current commit')
|
||||||
return False
|
return 'failed'
|
||||||
if not self.latest_commit:
|
if not self.latest_commit:
|
||||||
self.logger.error('Failed to get latest commit')
|
self.logger.error('Failed to get latest commit')
|
||||||
return False
|
return 'failed'
|
||||||
if self.current_commit == self.latest_commit:
|
if self.current_commit == self.latest_commit:
|
||||||
self.logger.info('Already up to date')
|
self.logger.info('Already up to date')
|
||||||
return True
|
return 'uptodate'
|
||||||
return False
|
self.logger.info('Current repo is behind remote')
|
||||||
|
return 'behind'
|
||||||
|
|
||||||
def update(self, keep_changes=False):
|
def update(self, keep_changes=False):
|
||||||
"""
|
"""
|
||||||
|
@ -70,12 +70,16 @@ class Updater(DeployConfig, GitManager, PipManager):
|
|||||||
self.state = "checking"
|
self.state = "checking"
|
||||||
|
|
||||||
if State.deploy_config.GitOverCdn:
|
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")
|
logger.info(f"No update")
|
||||||
return False
|
return False
|
||||||
else:
|
elif status == "behind":
|
||||||
logger.info(f"New update available")
|
logger.info(f"New update available")
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
# failed, should fallback to `git pull`
|
||||||
|
pass
|
||||||
|
|
||||||
source = "origin"
|
source = "origin"
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
|
Loading…
Reference in New Issue
Block a user