From 05adf763ba192e77c8aff6c6cd15cee6c7d698d3 Mon Sep 17 00:00:00 2001 From: houjingyang Date: Thu, 26 Mar 2026 18:19:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(bilibili):=20=E4=BC=98=E5=85=88=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=9C=AC=E5=9C=B0=E7=BC=93=E5=AD=98=E7=9A=84=20biliup?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E6=AF=8F=E6=AC=A1=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E9=83=BD=E5=BC=BA=E5=88=B6=E6=A3=80=E6=9F=A5=20GitHub=20Releas?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uploader/bilibili_uploader/runtime.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/uploader/bilibili_uploader/runtime.py b/uploader/bilibili_uploader/runtime.py index 6cfc869..a77b99c 100644 --- a/uploader/bilibili_uploader/runtime.py +++ b/uploader/bilibili_uploader/runtime.py @@ -153,10 +153,19 @@ def download_biliup_asset(release: dict, destination: Path) -> Path: def ensure_biliup_binary(force_check: bool = True) -> Path: binary_path = build_biliup_runtime_path() local_version = read_local_biliup_version() - if binary_path.exists() and local_version and not force_check: + + # 默认优先复用本地已存在的 biliup,避免每次执行都去请求 GitHub latest release。 + if binary_path.exists() and not force_check: return binary_path - release = fetch_latest_release() + try: + release = fetch_latest_release() + except Exception: + # 如果本地已经有可执行的 biliup,就在 GitHub 限流/网络失败时直接复用本地版本。 + if binary_path.exists(): + return binary_path + raise + latest_version = release["tag_name"] if binary_path.exists() and local_version == latest_version: return binary_path @@ -167,7 +176,7 @@ def ensure_biliup_binary(force_check: bool = True) -> Path: def run_biliup_command(arguments: list[str], interactive: bool = False) -> subprocess.CompletedProcess[str]: - binary_path = ensure_biliup_binary(force_check=True) + binary_path = ensure_biliup_binary(force_check=False) command = [str(binary_path), *arguments] if interactive: return subprocess.run(command, check=False)