diff --git a/common/check.py b/common/check.py index d94146e..179840f 100644 --- a/common/check.py +++ b/common/check.py @@ -1,6 +1,5 @@ import time -import ujson as json -from aiohttp import ClientError +from aiohttp import ClientError, ConnectionTimeoutError from .log import log from .stack_error import stack_error @@ -26,5 +25,7 @@ async def check_github_api_rate_limit(headers, session): except ClientError as e: log.error(f'⚠ 检查Github API 请求数失败,{stack_error(e)}') + except ConnectionTimeoutError as e: + log.error(f'⚠ 检查Github API 请求数超时: {stack_error(e)}') except Exception as e: log.error(f'⚠ 发生错误: {stack_error(e)}') diff --git a/common/main_func.py b/common/main_func.py index 051587b..940b27f 100644 --- a/common/main_func.py +++ b/common/main_func.py @@ -1,5 +1,5 @@ import os -from aiohttp import ClientSession +from aiohttp import ClientSession, ConnectionTimeoutError from common.config import config from common.dkey_merge import depotkey_merge @@ -22,6 +22,9 @@ async def fetch_branch_info(session, url, headers): except Exception as e: log.error(f'⚠ 获取信息失败: {stack_error(e)}') return None + except ConnectionTimeoutError as e: + log.error(f'⚠ 获取信息时超时: {stack_error(e)}') + return None async def get_latest_repo_info(session, repos, app_id, headers): latest_date = None diff --git a/common/manifest_down.py b/common/manifest_down.py index 8471728..d2d55d0 100644 --- a/common/manifest_down.py +++ b/common/manifest_down.py @@ -1,4 +1,4 @@ -from aiohttp import ClientError +from aiohttp import ClientError, ConnectionTimeoutError from tqdm.asyncio import tqdm_asyncio from .log import log @@ -12,21 +12,6 @@ async def get(sha: str, path: str, repo: str, session, chunk_size: int = 1024) - f'https://raw.dgithub.xyz/{repo}/{sha}/{path}', f'https://raw.githubusercontent.com/{repo}/{sha}/{path}' ] - ''' - 下载时间 (20MB 从小到大): - https://jsdelivr.pai233.top/gh/{repo}@{sha}/{path} - 0.95秒 - https://cdn.jsdmirror.com/gh/{repo}@{sha}/{path} - 6.74秒 - https://raw.kkgithub.com/{repo}/{sha}/{path} - 6.76秒 - https://raw.dgithub.xyz/{repo}/{sha}/{path} - 8.30秒 - https://raw.gitmirror.com/{repo}/{sha}/{path} - 15.60秒 - https://ghproxy.net/https://raw.githubusercontent.com/{repo}/{sha}/{path} - 16.59秒 - https://fastly.jsdelivr.net/gh/{repo}@{sha}/{path} - 20.08秒 - https://jsd.onmicrosoft.cn/gh/{repo}@{sha}/{path} - 22.07秒 - https://gitdl.cn/https://raw.githubusercontent.com/{repo}/{sha}/{path} - 47.33秒 - https://ghp.ci/https://raw.githubusercontent.com/{repo}/{sha}/{path} - 96.56秒 - https://raw.githubusercontent.com/{repo}/{sha}/{path} - 458.75秒 - https://cdn.jsdelivr.net/gh/{repo}@{sha}/{path} - 下载时出错 - ''' retry = 3 while retry > 0: for url in url_list: @@ -46,6 +31,8 @@ async def get(sha: str, path: str, repo: str, session, chunk_size: int = 1024) - log.error(f'🔄 获取失败: {path} - 状态码: {response.status}') except ClientError as e: log.error(f'🔄 获取失败: {path} - 连接错误: {str(e)}') + except ConnectionTimeoutError as e: + log.error(f'🔄 连接超时: {url} - 错误: {str(e)}') retry -= 1 log.warning(f'🔄 重试剩余次数: {retry} - {path}') diff --git a/common/migration.py b/common/migration.py index 13a134e..2df82e6 100644 --- a/common/migration.py +++ b/common/migration.py @@ -1,5 +1,6 @@ import subprocess import aiofiles +from aiohttp import ConnectionTimeoutError from pathlib import Path from tqdm.asyncio import tqdm from .log import log @@ -30,6 +31,8 @@ async def download_setup_file(session) -> None: log.error('⚠ 网络错误,无法下载安装程序') except Exception as e: log.error(f'⚠ 下载失败: {e}') + except ConnectionTimeoutError as e: + log.error(f'⚠ 下载时超时: {e}') async def migrate(st_use: bool, session) -> None: if st_use: