Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(download): remove github proxy fallback

t8y2b6bf3009f850
diff --git a/crates/dbx-core/src/lib.rs b/crates/dbx-core/src/lib.rs
index d2973e96a8..c9a8e5ca15 100644
--- a/crates/dbx-core/src/lib.rs
+++ b/crates/dbx-core/src/lib.rs
@@ -24,7 +24,9 @@ pub mod update;
pub const R2_CDN_BASE: &str = "https://dl.dbxio.com/";
-pub const GITHUB_PROXIES: &[&str] = &["https://gh-proxy.org/", ""];
+pub fn download_candidate_urls(github_url: &str, r2_path: &str) -> Vec<String> {
+ vec![format!("{R2_CDN_BASE}{r2_path}"), github_url.to_string()]
+}
pub async fn race_download(
client: &reqwest::Client,
@@ -35,28 +37,11 @@ pub async fn race_download(
use futures::future::select_ok;
use std::pin::Pin;
+ let urls = download_candidate_urls(github_url, r2_path);
let mut futs: Vec<Pin<Box<dyn std::future::Future<Output = Result<reqwest::Response, String>> + Send>>> =
- Vec::with_capacity(GITHUB_PROXIES.len() + 1);
-
- // R2 CDN source
- {
- let url = format!("{R2_CDN_BASE}{r2_path}");
- let client = client.clone();
- let ua = user_agent.to_string();
- futs.push(Box::pin(async move {
- client
- .get(&url)
- .header(reqwest::header::USER_AGENT, ua)
- .send()
- .await
- .and_then(|r| r.error_for_status())
- .map_err(|e| format!("{e}"))
- }));
- }
+ Vec::with_capacity(urls.len());
- // GitHub proxies + direct
- for proxy in GITHUB_PROXIES {
- let url = format!("{proxy}{github_url}");
+ for url in urls {
let client = client.clone();
let ua = user_agent.to_string();
futs.push(Box::pin(async move {
@@ -75,3 +60,24 @@ pub async fn race_download(
Err(last_err) => Err(last_err),
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::download_candidate_urls;
+
+ #[test]
+ fn download_candidates_exclude_third_party_github_proxy() {
+ let urls = download_candidate_urls(
+ "https://github.com/t8y2/dbx/releases/latest/download/latest.json",
+ "releases/latest/latest.json",
+ );
+
+ assert_eq!(
+ urls,
+ vec![
+ "https://dl.dbxio.com/releases/latest/latest.json",
+ "https://github.com/t8y2/dbx/releases/latest/download/latest.json",
+ ]
+ );
+ }
+}
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index b8d4142889..801f6100be 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -59,7 +59,6 @@
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkxNEYyMzE3QkJCNkM3REYKUldUZng3YTdGeU5Qa1NnTUZCRVhJVkxsOWZKQWFPVCtacUgySlNlcjRDU2RmZElCQnphd25pYUMK",
"endpoints": [
"https://dl.dbxio.com/releases/latest/latest.json",
- "https://gh-proxy.org/https://github.com/t8y2/dbx/releases/latest/download/latest.json",
"https://github.com/t8y2/dbx/releases/latest/download/latest.json"
]
}