From 11a2a09bf60dd0c3630aee4e55edbe9c083cb11e Mon Sep 17 00:00:00 2001 From: developer-wlj <55836679+developer-wlj@users.noreply.github.com> Date: Sun, 13 Sep 2026 21:06:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(update):=20=E6=B7=BB=E5=8A=A0exe=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20(#6668)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adapters/system/update.py | 39 ++++++++++++++++++++++++++++++++--- app/foundation/environment.py | 10 +++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/adapters/system/update.py b/app/adapters/system/update.py index 150875d0d..cbb7582fa 100644 --- a/app/adapters/system/update.py +++ b/app/adapters/system/update.py @@ -18,7 +18,7 @@ from typing import Any, cast from app.adapters.network.http import RequestUtils from app.adapters.system.resource import ResourceHelper, get_resource_versions -from app.foundation.environment import is_docker +from app.foundation.environment import is_docker, is_exe from app.foundation.singleton import SingletonClass from app.foundation.version import compare_version from app.runtime.dependencies.profile import runtime_sync_arguments @@ -559,7 +559,8 @@ class SystemUpdateManager(metaclass=SingletonClass): try: prepared = self._read_prepared_manifest() if target == _APPLICATION: - self._validate_application_manifest(prepared) + if not is_exe(): + self._validate_application_manifest(prepared) message = "主程序更新包已就绪,正在重启安装" else: self._validate_resource_manifest(prepared) @@ -1075,7 +1076,10 @@ class SystemUpdateManager(metaclass=SingletonClass): """在后台线程中下载并校验指定升级类型的制品。""" try: if target == _APPLICATION: - self._download_application() + if is_exe(): + self._simulate_application_download() + else: + self._download_application() else: self._download_resources() except Exception as error: # noqa: BLE001 后台线程必须沉淀为可查询失败 @@ -1086,6 +1090,35 @@ class SystemUpdateManager(metaclass=SingletonClass): self._download_active = False self._active_target = None + def _simulate_application_download(self) -> None: + """exe 部署下模拟主程序下载,直接写入准备清单并反馈完成。""" + if get_runtime_setting("MOVIEPILOT_AUTO_UPDATE") is not True: + raise RuntimeError("请先在高级设置里启用自动检查版本更新") + target_item = self._get_item(self._read_state(), _APPLICATION) + version = str(target_item.get("version") or "") + if not version: + raise RuntimeError("主程序更新缺少目标版本") + self._merge_prepared_manifest( + { + "version": version, + "frontend_version": version, + "backend_archive": str(self._backend_archive), + "frontend_archive": str(self._frontend_archive), + "backend_sha256": "", + "frontend_sha256": "", + "prepared_at": self._now(), + }, + ) + self._write_item( + _APPLICATION, + state="ready", + downloaded_bytes=100, + total_bytes=100, + error=None, + can_update=False, + can_install=True, + ) + def _download_application(self) -> None: """下载后端 Release 和其 version.py 声明的前端 dist.zip。""" target = self._get_item(self._read_state(), _APPLICATION) diff --git a/app/foundation/environment.py b/app/foundation/environment.py index b92a58bf6..5e831bdaf 100644 --- a/app/foundation/environment.py +++ b/app/foundation/environment.py @@ -33,6 +33,16 @@ def is_windows() -> bool: return os.name == "nt" +def is_exe() -> bool: + """判断当前是否为 MoviePilot-V3.exe 部署环境。""" + if not is_windows(): + return False + try: + return Path.exists(Path(__file__).parents[4] / "MoviePilot-V3.exe") + except PermissionError: + return False + + def is_macos() -> bool: """判断当前操作系统是否为 macOS。""" return platform.system() == "Darwin"