This commit is contained in:
wess09 2026-05-12 17:26:34 +08:00
parent cb8c432e09
commit c106031760
3 changed files with 19 additions and 22 deletions

View File

@ -131,6 +131,7 @@ class DeployConfig(ConfigModel):
'https://gitcode.com/nerom/AzurLaneAutoScript',
'https://gitee.com/wqeaxc/AzurLaneAutoScript1',
'https://git.nanoda.work/git/AzurLaneAutoScript',
'https://git.nanoda.work/git/AzurPilot',
'https://git.nanoda.work',
]:
self.Repository = GIT_OVER_CDN_REPOSITORY

View File

@ -1,6 +1,6 @@
import requests
from deploy.config import DeployConfig
from deploy.config import DeployConfig, ExecutionError
from deploy.git_over_cdn.client import GitOverCdnClient
from deploy.logger import logger
from deploy.utils import *
@ -95,7 +95,7 @@ class GitManager(DeployConfig):
resp.raise_for_status()
except Exception as e:
logger.warning(f'Failed to check cloud update control: {e}')
return False
return None
text = resp.text.strip()
try:
@ -110,6 +110,14 @@ class GitManager(DeployConfig):
logger.info(f'Cloud update control is disabled: {text}')
return False
def cloud_update_access_failed(self):
logger.hr('Cloud Update Control Failed', 0)
logger.warning('Failed to access cloud update control, stopping startup')
alas_kill = getattr(self, 'alas_kill', None)
if callable(alas_kill):
alas_kill()
raise ExecutionError
def git_install(self):
logger.hr('Update Alas', 0)
@ -117,7 +125,10 @@ class GitManager(DeployConfig):
logger.info('AutoUpdate is disabled, skip')
return
if not self.cloud_auto_update_enabled():
cloud_update = self.cloud_auto_update_enabled()
if cloud_update is None:
self.cloud_update_access_failed()
if not cloud_update:
logger.info('Cloud update control disabled, skip')
return

View File

@ -68,25 +68,10 @@ class Updater(DeployConfig, GitManager, PipManager):
def _check_cloud_update(self) -> bool:
"""检查云端更新开关"""
try:
resp = requests.get("https://alas-apiv2.nanoda.work/api/updata", timeout=5)
if resp.status_code == 200:
data = resp.text.strip().lower()
if data == 'true':
return True
elif data == 'false':
return False
else:
try:
import json
res = json.loads(data)
if isinstance(res, bool):
return res
except:
pass
except Exception as e:
logger.warning(f"Failed to fetch cloud update flag: {e}")
return False
cloud_update = self.cloud_auto_update_enabled()
if cloud_update is None:
raise ExecutionError
return cloud_update
def _check_update(self) -> bool:
self.state = "checking"