fix(updater): use visible full installer by default

This commit is contained in:
Your Name committed 2026-06-29 02:19:14 +08:00
1 parent 1c686a6595
commit e24b0bdd1e
2 files changed
+53 -9

No files matched your search

+12 -4
View File
@@ -25,8 +25,6 @@ from douyin.license.public_key import PUBLIC_KEY_PEM
DEFAULT_INSTALLER_ARGS = (
"/VERYSILENT",
"/SUPPRESSMSGBOXES",
"/NORESTART",
"/CURRENTUSER",
)
@@ -49,6 +47,7 @@ class UpdateSettings:
require_https: bool = True
allow_cross_origin: bool = False
require_signed_manifest: bool = False
allow_delta: bool = False
@dataclass(frozen=True)
@@ -196,6 +195,10 @@ def load_update_settings() -> UpdateSettings:
require_https=_to_bool(section.get("require_https"), not using_default_manifest),
allow_cross_origin=_to_bool(section.get("allow_cross_origin"), False),
require_signed_manifest=_to_bool(section.get("require_signed_manifest"), using_default_manifest),
allow_delta=_to_bool(
os.environ.get("DOUYIN_UPDATE_ALLOW_DELTA", section.get("allow_delta")),
False,
),
)
@@ -697,11 +700,16 @@ def perform_forced_update(
installer_path=installer_path,
)
delta = _matching_delta(manifest, current_version, latest_version)
delta = _matching_delta(manifest, current_version, latest_version) if settings.allow_delta else None
if not delta:
unavailable_message = (
"未找到当前版本可用的差量包,准备下载完整安装包"
if settings.allow_delta
else "准备下载完整安装包"
)
emit_progress(
"delta_unavailable",
message="未找到当前版本可用的差量包,准备下载完整安装包",
message=unavailable_message,
current_version=current_version,
latest_version=latest_version,
)
+41 -5
View File
@@ -142,6 +142,17 @@ def test_forced_update_downloads_verifies_and_launches_installer(tmp_path):
assert any(arg.startswith("/LOG=") for arg in launched[0])
def test_default_update_settings_launch_visible_installer_and_disable_delta(tmp_path):
from douyin.updater.force_update import DEFAULT_INSTALLER_ARGS, UpdateSettings
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
assert "/VERYSILENT" not in DEFAULT_INSTALLER_ARGS
assert "/SILENT" not in DEFAULT_INSTALLER_ARGS
assert "/SUPPRESSMSGBOXES" not in DEFAULT_INSTALLER_ARGS
assert settings.allow_delta is False
def test_forced_update_prefers_matching_delta_package(tmp_path):
from douyin.updater.force_update import UpdateSettings, perform_forced_update
@@ -167,7 +178,12 @@ def test_forced_update_prefers_matching_delta_package(tmp_path):
zf.writestr("files/DouyinGuajiGUI.exe", file_payload)
delta_payload = delta_zip.read_bytes()
delta_sha = hashlib.sha256(delta_payload).hexdigest()
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
settings = UpdateSettings(
enabled=True,
manifest_url="https://example.test/update.json",
download_dir=tmp_path,
allow_delta=True,
)
downloaded: list[str] = []
launched: list[Path] = []
@@ -230,7 +246,12 @@ def test_forced_update_picks_matching_delta_from_list(tmp_path):
zf.writestr("files/DouyinGuajiGUI.exe", file_payload)
delta_payload = delta_zip.read_bytes()
delta_sha = hashlib.sha256(delta_payload).hexdigest()
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
settings = UpdateSettings(
enabled=True,
manifest_url="https://example.test/update.json",
download_dir=tmp_path,
allow_delta=True,
)
downloaded: list[str] = []
def download(url: str, dest: Path, timeout: float) -> None:
@@ -275,7 +296,12 @@ def test_forced_update_falls_back_to_full_installer_when_delta_download_fails(tm
full_payload = b"full installer"
full_sha = hashlib.sha256(full_payload).hexdigest()
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
settings = UpdateSettings(
enabled=True,
manifest_url="https://example.test/update.json",
download_dir=tmp_path,
allow_delta=True,
)
downloaded: list[str] = []
launched: list[list[str]] = []
@@ -326,7 +352,12 @@ def test_forced_update_logs_delta_failure_before_full_fallback(tmp_path, monkeyp
full_sha = hashlib.sha256(full_payload).hexdigest()
logs_dir = tmp_path / "logs"
monkeypatch.setattr(path_config, "get_logs_dir", lambda: str(logs_dir))
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
settings = UpdateSettings(
enabled=True,
manifest_url="https://example.test/update.json",
download_dir=tmp_path,
allow_delta=True,
)
def fetch_manifest(url: str, timeout: float) -> dict:
return {
@@ -394,7 +425,12 @@ def test_forced_update_skips_delta_after_previous_started_attempt_still_old_vers
zf.writestr("files/DouyinGuajiGUI.exe", file_payload)
delta_payload = delta_zip.read_bytes()
delta_sha = hashlib.sha256(delta_payload).hexdigest()
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
settings = UpdateSettings(
enabled=True,
manifest_url="https://example.test/update.json",
download_dir=tmp_path,
allow_delta=True,
)
launched_installers: list[list[str]] = []
launched_deltas: list[Path] = []