feat(update): securely stage verified packages

This commit is contained in:
chengma
2026-07-13 12:02:47 +08:00
parent 567d4e7b68
commit 3ad9ffd239
8 changed files with 616 additions and 3 deletions
+24
View File
@@ -27,6 +27,10 @@ class UpdateInfo:
force_update: bool = False
download_url: str = ""
sha256: str = ""
size_bytes: int = 0
package_format: str = ""
updater_protocol: int = 0
min_updater_protocol: int = 0
message: str = ""
@@ -39,6 +43,10 @@ class UpdateCheckResult:
min_supported_version: str = ""
download_url: str = ""
sha256: str = ""
size_bytes: int = 0
package_format: str = ""
updater_protocol: int = 0
min_updater_protocol: int = 0
message: str = ""
error: str = ""
@@ -111,6 +119,18 @@ def parse_update_info(payload) -> UpdateInfo:
force_update=_as_bool(payload.get("force_update", release.get("force_update"))),
download_url=str(payload.get("download_url") or release.get("download_url") or "").strip(),
sha256=str(payload.get("sha256") or release.get("sha256") or "").strip(),
size_bytes=int(payload.get("size_bytes") or release.get("size_bytes") or 0),
package_format=str(
payload.get("package_format") or release.get("package_format") or ""
).strip(),
updater_protocol=int(
payload.get("updater_protocol") or release.get("updater_protocol") or 0
),
min_updater_protocol=int(
payload.get("min_updater_protocol")
or release.get("min_updater_protocol")
or 0
),
message=str(
payload.get("message")
or payload.get("release_notes")
@@ -178,6 +198,10 @@ def check_for_update(
min_supported_version=info.min_supported_version,
download_url=info.download_url,
sha256=info.sha256,
size_bytes=info.size_bytes,
package_format=info.package_format,
updater_protocol=info.updater_protocol,
min_updater_protocol=info.min_updater_protocol,
message=info.message,
)
except Exception as exc: