mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-29 02:57:25 +00:00
Add: Use GitOverCdn at GUI update check
This commit is contained in:
parent
2f845bde98
commit
bdbbc68777
@ -128,14 +128,14 @@ class GitManager(DeployConfig):
|
|||||||
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
|
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
|
||||||
Progress.GitShowVersion()
|
Progress.GitShowVersion()
|
||||||
|
|
||||||
def git_over_cdn(self):
|
@property
|
||||||
|
def goc_client(self):
|
||||||
client = GitOverCdnClient(
|
client = GitOverCdnClient(
|
||||||
url='https://vip.123pan.cn/1815343254/pack/LmeSzinc_StarRailCopilot_master',
|
url='https://vip.123pan.cn/1815343254/pack/LmeSzinc_StarRailCopilot_master',
|
||||||
folder=self.root_filepath,
|
folder=self.root_filepath,
|
||||||
)
|
)
|
||||||
client.logger = logger
|
client.logger = logger
|
||||||
_ = client.update(keep_changes=self.KeepLocalChanges)
|
return client
|
||||||
return _
|
|
||||||
|
|
||||||
def git_install(self):
|
def git_install(self):
|
||||||
logger.hr('Update Alas', 0)
|
logger.hr('Update Alas', 0)
|
||||||
@ -146,7 +146,7 @@ class GitManager(DeployConfig):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if self.GitOverCdn:
|
if self.GitOverCdn:
|
||||||
if self.git_over_cdn():
|
if self.goc_client.update(keep_changes=self.KeepLocalChanges):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.git_repository_init(
|
self.git_repository_init(
|
||||||
|
@ -215,6 +215,23 @@ 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):
|
||||||
|
"""
|
||||||
|
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):
|
def update(self, keep_changes=False):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
|
@ -68,6 +68,15 @@ class Updater(DeployConfig, GitManager, PipManager):
|
|||||||
|
|
||||||
def _check_update(self) -> bool:
|
def _check_update(self) -> bool:
|
||||||
self.state = "checking"
|
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"
|
source = "origin"
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
if self.execute(
|
if self.execute(
|
||||||
|
Loading…
Reference in New Issue
Block a user