feat(agent): support offline driver import via ZIP bundle and local JAR

Add two offline import methods for users behind corporate firewalls:
- ZIP offline bundle: import all drivers + JRE from a single ZIP file
- Single JAR import: import individual driver JARs per database type
This commit is contained in:
t8y2
2026-05-20 09:44:03 +08:00
parent 49a7541450
commit 98e2d03f64
9 changed files with 336 additions and 3 deletions
+38 -1
View File
@@ -7,7 +7,8 @@ use dbx_core::agent_manager::{
};
use dbx_core::agent_service::{
build_agent_list, download_temp_path, fetch_registry, find_local_agent_jar, github_url_to_r2_path,
install_local_agent, invalidate_registry_cache, replace_download,
import_agent_jar, import_offline_zip, install_local_agent, invalidate_registry_cache, replace_download,
OfflineImportProgress,
};
use dbx_core::connection::AppState;
@@ -288,6 +289,42 @@ pub async fn invalidate_agent_registry_cache() -> Result<(), String> {
Ok(())
}
#[tauri::command]
pub async fn import_agents_from_zip(
app: tauri::AppHandle,
state: State<'_, Arc<AppState>>,
path: String,
) -> Result<u32, String> {
let am = &state.agent_manager;
let zip_path = std::path::PathBuf::from(&path);
let app_handle = app.clone();
let result = import_offline_zip(am, &zip_path, |p: OfflineImportProgress| {
let _ = app_handle.emit(
"agent-install-progress",
serde_json::json!({
"step": p.step,
"downloaded": p.current as u64,
"total": p.total as u64,
"db_type": p.label,
"current": p.current,
"total_drivers": p.total,
}),
);
})?;
let count = result.drivers_installed.len() as u32;
let _ = app.emit("agent-install-progress", serde_json::json!({ "step": "done" }));
Ok(count)
}
#[tauri::command]
pub async fn import_agent_jar_cmd(
state: State<'_, Arc<AppState>>,
db_type: String,
path: String,
) -> Result<(), String> {
import_agent_jar(&state.agent_manager, &db_type, std::path::Path::new(&path))
}
#[tauri::command]
pub async fn reinstall_jre(
app: tauri::AppHandle,
+2
View File
@@ -255,6 +255,8 @@ pub fn run() {
commands::agents::uninstall_jre,
commands::agents::reinstall_jre,
commands::agents::invalidate_agent_registry_cache,
commands::agents::import_agents_from_zip,
commands::agents::import_agent_jar_cmd,
])
.build(tauri::generate_context!())
.expect("error while building tauri application")