Peach: Local-first video metadata scraper and media manager.
fix(update): 下载站取不到时不拿 GitHub 的旧版本下结论
longmeidao95a6ebfd3df1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8f00f11f2..873494be2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,6 +28,7 @@ Removed / Fixed / Security。### 修复- **更新**:应用更新包与已装版本的更新器对不上时,改为下载同版本的完整包,不再停在「更新包工具清单无效」;以后随包工具增减也不会卡住自动更新。+- **更新**:官方下载站暂时连不上时,检查更新提示「未能取得版本信息,请重试」,不再拿 GitHub 上停在 0.46.1 的旧版本误报「已是最新」或「当前版本高于已发布测试版」。- **界面**:设置弹窗等新界面的中文统一用雅黑、苹方或思源黑体显示,繁体系统上不再混用正黑体而显得发虚。## [0.48.2] - 2026-10-24diff --git a/README.en.md b/README.en.mdindex bf3819d08..9e3f1afe6 100644--- a/README.en.md+++ b/README.en.md@@ -19,8 +19,8 @@</p><p align="center">- <a href="https://github.com/peach-mitao/peach/releases"><img src="https://img.shields.io/github/v/release/peach-mitao/peach?include_prereleases&filter=v*&sort=semver&display_name=tag" alt="release"></a>- <a href="https://github.com/peach-mitao/peach/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/peach-mitao/peach/test.yml?branch=master&label=tests&logo=githubactions&logoColor=white" alt="CI status"></a>+ <a href="https://gitgud.io/peach-mitao/peach/-/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdownloads.peach.video%2Freleases.json&query=%24%5B0%5D.tag_name&label=release" alt="release"></a>+ <a href="https://gitgud.io/peach-mitao/peach/-/pipelines?ref=master"><img src="https://img.shields.io/badge/CI-GitGud-554488?logo=gitlab&logoColor=white" alt="CI pipelines"></a><a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue?logo=gnu&logoColor=white" alt="license"></a><a href="docs/TESTING_DESKTOP.md"><img src="https://img.shields.io/badge/Windows-x64-0078D4" alt="Windows x64"></a><a href="docs/OPERATIONS.md#macos-独立测试包"><img src="https://img.shields.io/badge/macOS-DMG-555555?logo=apple&logoColor=white" alt="Build and install the standalone macOS app"></a>diff --git a/README.md b/README.mdindex 4dfa19df3..7ae744950 100644--- a/README.md+++ b/README.md@@ -19,8 +19,8 @@</p><p align="center">- <a href="https://github.com/peach-mitao/peach/releases"><img src="https://img.shields.io/github/v/release/peach-mitao/peach?include_prereleases&filter=v*&sort=semver&display_name=tag" alt="release"></a>- <a href="https://github.com/peach-mitao/peach/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/peach-mitao/peach/test.yml?branch=master&label=tests&logo=githubactions&logoColor=white" alt="CI 状态"></a>+ <a href="https://gitgud.io/peach-mitao/peach/-/releases"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdownloads.peach.video%2Freleases.json&query=%24%5B0%5D.tag_name&label=release" alt="release"></a>+ <a href="https://gitgud.io/peach-mitao/peach/-/pipelines?ref=master"><img src="https://img.shields.io/badge/CI-GitGud-554488?logo=gitlab&logoColor=white" alt="CI 流水线"></a><a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue?logo=gnu&logoColor=white" alt="license"></a><a href="docs/TESTING_DESKTOP.md"><img src="https://img.shields.io/badge/Windows-x64-0078D4" alt="Windows x64"></a><a href="docs/OPERATIONS.md#macos-独立测试包"><img src="https://img.shields.io/badge/macOS-DMG-555555?logo=apple&logoColor=white" alt="macOS 独立应用构建与安装"></a>diff --git a/src/peach/release_updates.py b/src/peach/release_updates.pyindex 0e45d3e08..e65c0bab9 100644--- a/src/peach/release_updates.py+++ b/src/peach/release_updates.py@@ -64,6 +64,7 @@ def check(*, transport=None) -> dict:try:releases = []obtained = False+ downloads = Falsefor endpoint in (DOWNLOADS_API, API_URL):try:headers = {"Accept": "application/json"}@@ -76,6 +77,7 @@ def check(*, transport=None) -> dict:if not isinstance(rows, list):continueobtained = True+ downloads = downloads or endpoint == DOWNLOADS_APIreleases.extend(_release_candidates(rows, endpoint))except (OSError, ValueError, TypeError, TimeoutError, httpx.HTTPError):continue@@ -87,6 +89,10 @@ def check(*, transport=None) -> dict:if current is None:raise ValueError("current version required")state = "available" if version > current else "ahead" if version < current else "current"+ if not downloads and state != "available":+ # 新版本只发在 R2;GitHub 上停在旧版本。R2 没取到时,GitHub 的旧版本既说明不了+ # 「已是最新」也说明不了「高于已发布版本」。+ return dict(result, state="error", message="未能取得版本信息,请重试。")message = {"available": "有新版本可下载。", "ahead": "当前版本高于已发布测试版。", "current": "已是最新测试版。"}[state]return dict(result, latest_version=tag.removeprefix("v"), state=state, message=message,asset_url=f"{directory}/{asset['name']}",diff --git a/tests/test_release_updates.py b/tests/test_release_updates.pyindex 25ee2537b..ae05b8405 100644--- a/tests/test_release_updates.py+++ b/tests/test_release_updates.py@@ -95,6 +95,23 @@ class ReleaseUpdateTests(unittest.TestCase):self.assertEqual(result["state"], "error")self.assertIsNone(result["latest_version"])+ def test_without_r2_an_older_github_release_is_no_answer(self):+ """新版本只发在 R2,GitHub 停在旧版本:R2 没取到时不能据 GitHub 说「已是最新」或「高于已发布版本」。"""+ def transport(github_version):+ def answer(request, *_args):+ if request.url == release_updates.DOWNLOADS_API:+ raise httpx.ConnectError("R2 unreachable")+ return HttpResponse(200, {}, json.dumps([release(github_version)]).encode())+ return answer++ with patch.object(release_updates, "__version__", "0.48.2"):+ for older in ("0.46.1", "0.48.2"):+ with self.subTest(github=older):+ result = release_updates.check(transport=transport(older))+ self.assertEqual((result["state"], result["message"]), ("error", "未能取得版本信息,请重试。"))+ self.assertEqual(release_updates.check(transport=transport("0.49.0"))["state"], "available",+ "GitHub 上真有更新的版本时照样可以升")+def test_standalone_tray_checks_releases_without_git(self):execute = Mock(side_effect=AssertionError("Git must not run"))with patch("peach.distribution.standalone", return_value=True), patch.object(