From 7b41e7f13d8a49d005f4186f069f35e72bacdc89 Mon Sep 17 00:00:00 2001
From: JoeAllen <2494136784@qq.com>
Date: Wed, 30 Sep 2026 12:54:57 +0800
Subject: [PATCH] =?UTF-8?q?feat(update):=20OTA=20=E5=85=9C=E5=BA=95?=
=?UTF-8?q?=E5=8F=91=E7=8E=B0=E4=B8=8E=E7=B3=BB=E7=BB=9F=E4=BB=A3=E7=90=86?=
=?UTF-8?q?=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- check_latest 加免 API 配额的兜底路径:api.github.com 被限流(60 次/
小时/IP,共享出口 IP 实测已打满)时,跟踪 github.com/releases/latest
的 302 从最终 URL 提取 tag,下载与 .sha256 按命名约定构造;notes 置空、
大小置 0(进度未知、对账跳过),sha256 校验仍强制执行
- ureq 启用 win-system-proxy:Windows 系统代理注册表设置自动生效;
HTTP(S)_PROXY 环境变量代理 ureq 默认就读取,无需配置
- 实测:github.com 直连与代理均可达(302 正常),api.github.com 直连
与代理出口 IP 的未认证配额均耗尽 —— 兜底路径为必需品而非锦上添花
---
Cargo.lock | 13 +++++-
gpui-app/Cargo.toml | 5 ++-
gpui-app/src/update/check.rs | 86 ++++++++++++++++++++++++++++++++++++
gpui-app/src/update/mod.rs | 4 ++
4 files changed, 105 insertions(+), 3 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 830abeb..b38f049 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1679,7 +1679,7 @@ dependencies = [
"rustc_version",
"toml 1.1.6+spec-1.1.0",
"vswhom",
- "winreg",
+ "winreg 0.55.0",
]
[[package]]
@@ -7890,6 +7890,7 @@ dependencies = [
"ureq-proto",
"utf8-zero",
"webpki-roots",
+ "winreg 0.56.0",
]
[[package]]
@@ -9182,6 +9183,16 @@ dependencies = [
"windows-sys 0.59.0",
]
+[[package]]
+name = "winreg"
+version = "0.56.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10"
+dependencies = [
+ "cfg-if",
+ "windows-sys 0.59.0",
+]
+
[[package]]
name = "wio"
version = "0.2.2"
diff --git a/gpui-app/Cargo.toml b/gpui-app/Cargo.toml
index f48e62a..8ba8131 100644
--- a/gpui-app/Cargo.toml
+++ b/gpui-app/Cargo.toml
@@ -41,8 +41,9 @@ rustls-native-certs = "0.8"
# 原生文件对话框(连接导入/导出);Windows 走内建 COM 后端,Linux 用默认 xdg-portal
rfd = "0.17"
-# OTA 自更新:Gitea Release 检查/下载(ureq 用 rustls,与 rumqttc 依赖同源)
-ureq = { version = "3", features = ["json"] }
+# OTA 自更新:GitHub Release 检查/下载(ureq 用 rustls,与 rumqttc 依赖同源;
+# win-system-proxy 使 Windows 系统代理注册表设置自动生效,环境变量代理本就默认支持)
+ureq = { version = "3", features = ["json", "win-system-proxy"] }
sha2 = "0.11"
# Release 附件为 7z 压缩包,纯 Rust 解压(客户端免装 7-Zip)
sevenz-rust = "0.6"
diff --git a/gpui-app/src/update/check.rs b/gpui-app/src/update/check.rs
index 9671fa6..491eef1 100644
--- a/gpui-app/src/update/check.rs
+++ b/gpui-app/src/update/check.rs
@@ -69,6 +69,19 @@ pub fn pick_assets(rel: &serde_json::Value) -> Option<(String, String, u64, Opti
/// 检查更新。返回 Ok(None) 表示已是最新。
pub fn check_latest() -> Result