Add: Use GitOverCdn at GUI update check

This commit is contained in:
LmeSzinc 2023-09-10 18:00:47 +08:00
parent 2f845bde98
commit bdbbc68777
3 changed files with 30 additions and 4 deletions

View File

@ -128,14 +128,14 @@ class GitManager(DeployConfig):
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
Progress.GitShowVersion()
def git_over_cdn(self):
@property
def goc_client(self):
client = GitOverCdnClient(
url='https://vip.123pan.cn/1815343254/pack/LmeSzinc_StarRailCopilot_master',
folder=self.root_filepath,
)
client.logger = logger
_ = client.update(keep_changes=self.KeepLocalChanges)
return _
return client
def git_install(self):
logger.hr('Update Alas', 0)
@ -146,7 +146,7 @@ class GitManager(DeployConfig):
return
if self.GitOverCdn:
if self.git_over_cdn():
if self.goc_client.update(keep_changes=self.KeepLocalChanges):
return
self.git_repository_init(

View File

@ -215,6 +215,23 @@ class GitOverCdnClient:
else:
self.git_command('reset', '--hard', f'{self.source}/{self.branch}')
def is_uptodate(self):
"""
Returns:
bool: If repo is up-to-date
"""
_ = self.current_commit
_ = self.latest_commit
if not self.current_commit:
self.logger.error('Failed to get current commit')
return False
if not self.latest_commit:
self.logger.error('Failed to get latest commit')
return False
if self.current_commit == self.latest_commit:
self.logger.info('Already up to date')
return True
def update(self, keep_changes=False):
"""
Args:

View File

@ -68,6 +68,15 @@ class Updater(DeployConfig, GitManager, PipManager):
def _check_update(self) -> bool:
self.state = "checking"
if State.deploy_config.GitOverCdn:
if self.goc_client.is_uptodate():
logger.info(f"No update")
return False
else:
logger.info(f"New update available")
return True
source = "origin"
for _ in range(3):
if self.execute(