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