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(agent): add cache buster to R2 downloads

t8y2db7b730dd37e
diff --git a/crates/dbx-core/src/agent_service.rs b/crates/dbx-core/src/agent_service.rs
index 6ed0d7b9b6..587db10738 100644
--- a/crates/dbx-core/src/agent_service.rs
+++ b/crates/dbx-core/src/agent_service.rs
@@ -413,7 +413,7 @@ pub async fn reinstall_agent_jre(
&progress,
"jre",
&platform_jre.url,
- &github_url_to_r2_path(&platform_jre.url, "jre"),
+ &r2_path_with_cache_buster(&github_url_to_r2_path(&platform_jre.url, "jre"), &jre_info.version),
&jre_archive,
platform_jre.size,
Some(CacheIdentity::Jre { key: jre_key, version: &jre_info.version }),
@@ -519,7 +519,7 @@ async fn install_agent_driver_from_registry(
progress,
"jre",
&platform_jre.url,
- &github_url_to_r2_path(&platform_jre.url, "jre"),
+ &r2_path_with_cache_buster(&github_url_to_r2_path(&platform_jre.url, "jre"), &jre_info.version),
&jre_archive,
platform_jre.size,
Some(CacheIdentity::Jre { key: jre_key, version: &jre_info.version }),
@@ -557,7 +557,7 @@ async fn install_agent_driver_from_registry(
progress,
"driver",
&artifact.url,
- &github_url_to_r2_path(&artifact.url, "driver"),
+ &r2_path_with_cache_buster(&github_url_to_r2_path(&artifact.url, "driver"), &driver.version),
&target_path,
artifact.size,
Some(CacheIdentity::Driver { db_type, version: &driver.version }),
@@ -774,6 +774,11 @@ fn cache_file_token(value: &str) -> String {
}
}
+fn r2_path_with_cache_buster(r2_path: &str, version: &str) -> String {
+ let separator = if r2_path.contains('?') { '&' } else { '?' };
+ format!("{r2_path}{separator}v={}", cache_file_token(version))
+}
+
pub fn github_url_to_r2_path(github_url: &str, category: &str) -> String {
let filename = github_url.rsplit('/').next().unwrap_or(github_url);
match category {
@@ -1040,6 +1045,27 @@ pub fn import_agent_jar(am: &AgentManager, db_type: &str, jar_path: &Path) -> Re
// ──────────── Tests ────────────
+#[cfg(test)]
+mod agent_download_url_tests {
+ use super::*;
+
+ #[test]
+ fn r2_cache_buster_uses_version_query() {
+ assert_eq!(
+ r2_path_with_cache_buster("agents/jre/dbx-jre-21-macos-x64.tar.gz", "21.0.11+7"),
+ "agents/jre/dbx-jre-21-macos-x64.tar.gz?v=21.0.11-7"
+ );
+ }
+
+ #[test]
+ fn r2_cache_buster_preserves_existing_query() {
+ assert_eq!(
+ r2_path_with_cache_buster("agents/drivers/dbx-agent-h2.jar?mirror=r2", "0.5.33"),
+ "agents/drivers/dbx-agent-h2.jar?mirror=r2&v=0.5.33"
+ );
+ }
+}
+
#[cfg(test)]
mod jre_dir_remove_tests {
use super::*;