From f84e31d8e0544aab2b45ceec3e5f7a86f48c00aa Mon Sep 17 00:00:00 2001 From: Estrella Pan Date: Sat, 24 Oct 2026 11:09:21 +0200 Subject: [PATCH] =?UTF-8?q?fix(update):=20=E9=95=9C=E5=83=8F=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=97=A0=E6=B3=95=E8=A7=A3=E6=9E=90=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E4=BB=BB=E4=BD=95=E6=9B=B4=E6=96=B0=EF=BC=88?= =?UTF-8?q?Codex=20=E5=AE=A1=E6=9F=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/module/update/updater.py | 4 +++- backend/src/test/test_update.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/module/update/updater.py b/backend/src/module/update/updater.py index 196429a1..bafda206 100644 --- a/backend/src/module/update/updater.py +++ b/backend/src/module/update/updater.py @@ -217,6 +217,7 @@ class Updater: async def _fetch_releases(self) -> list[dict]: client = await self._get_client() + # ponytail: 只取第一页;之后的 4.x 发布超过 100 个时,再按页往后找 3.x url = f"{_API_BASE}/repos/{self.owner}/{self.repo}/releases?per_page=100" resp = await client.get(url, headers=_API_HEADERS) resp.raise_for_status() @@ -281,7 +282,8 @@ class Updater: ver = _parse_semver(rel.get("tag_name") or "") if ver is None: continue - if image is not None and ver.major != image.major: + # 镜像版本无法解析(开发/本地构建)时 _image_supports 拒绝任何更新包 + if image is None or ver.major != image.major: continue candidates.append((ver, rel)) if not candidates: diff --git a/backend/src/test/test_update.py b/backend/src/test/test_update.py index 77732462..a96b4ca6 100644 --- a/backend/src/test/test_update.py +++ b/backend/src/test/test_update.py @@ -249,6 +249,14 @@ class TestCheckUpdate: assert picked is not None assert picked["tag_name"] == expected + def test_unparseable_image_version_is_offered_nothing(self, tmp_path): + """开发/本地构建不能应用更新包,也不应提示有更新。""" + releases = [{"tag_name": "3.3.7", "prerelease": False}] + up = Updater( + root=tmp_path / "u", current_version="3.3.6", image_version="DEV_VERSION" + ) + assert up._pick_release(releases, "stable") is None + @pytest.mark.asyncio async def test_no_update_when_current_is_latest(self, tmp_path, bundle): data, sha = bundle