From 207e1112dccc7ad402e10cfc6c673a9863f69c63 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 16 Sep 2026 15:52:42 +0800 Subject: [PATCH] fix(update): refresh current application version --- app/adapters/system/update.py | 6 ++++-- tests/test_system_update_manager.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/adapters/system/update.py b/app/adapters/system/update.py index e664ee515..3f2b565fc 100644 --- a/app/adapters/system/update.py +++ b/app/adapters/system/update.py @@ -235,12 +235,14 @@ class SystemUpdateManager(metaclass=SingletonClass): return next(item for item in state["updates"] if item["type"] == target) def _sync_aggregate(self, state: dict[str, Any]) -> dict[str, Any]: - """从两类明细重新计算旧版顶层字段和汇总进度。""" + """从两类明细重新计算旧版顶层字段、当前版本和汇总进度。""" application = self._get_item(state, _APPLICATION) + current_version = get_app_version() + application["current_version"] = current_version state.update( { "state": application.get("state", "idle"), - "current_version": get_app_version(), + "current_version": current_version, "version": application.get("version"), "frontend_version": application.get("frontend_version"), "release_name": application.get("release_name"), diff --git a/tests/test_system_update_manager.py b/tests/test_system_update_manager.py index 71a20ec48..c59122762 100644 --- a/tests/test_system_update_manager.py +++ b/tests/test_system_update_manager.py @@ -153,6 +153,20 @@ def test_check_logs_when_application_is_current(monkeypatch, tmp_path): assert logs == ["MoviePilot 主程序已是最新版本:v3.0.0"] +def test_status_refreshes_stale_application_version(monkeypatch, tmp_path): + """旧状态文件中的主程序版本应在读取时更新为当前运行版本。""" + manager = _manager(monkeypatch, tmp_path) + monkeypatch.setattr(update_module, "get_app_version", lambda: "v3.0.0") + manager._write_item("application", state="idle") + + monkeypatch.setattr(update_module, "get_app_version", lambda: "v3.0.3") + status = manager.get_status() + application = next(item for item in status.updates if item.type == "application") + + assert status.current_version == "v3.0.3" + assert application.current_version == "v3.0.3" + + def test_public_download_request_omits_github_authorization(monkeypatch, tmp_path): """公开归档下载不得复用 GitHub API 的认证请求头。""" manager = _manager(monkeypatch, tmp_path)