perf(tauri): move blocking command work off async runtime
This commit is contained in:
1 parent
a5d9addbf3
commit
348f39ff35
11 files changed
+135
-64
No files matched your search
@@ -8,7 +8,10 @@ use super::connection::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_plugins(state: State<'_, Arc<AppState>>) -> Result<Vec<InstalledPlugin>, String> {
|
||||
state.plugins.list_installed()
|
||||
let root_dir = state.plugins.root_dir().to_path_buf();
|
||||
tauri::async_runtime::spawn_blocking(move || dbx_core::plugins::PluginRegistry::new(root_dir).list_installed())
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -31,12 +34,18 @@ pub async fn install_jdbc_plugin_local(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn uninstall_jdbc_plugin(state: State<'_, Arc<AppState>>) -> Result<JdbcPluginStatus, String> {
|
||||
jdbc::uninstall_jdbc_plugin(state.plugins.root_dir())
|
||||
let root_dir = state.plugins.root_dir().to_path_buf();
|
||||
tauri::async_runtime::spawn_blocking(move || jdbc::uninstall_jdbc_plugin(&root_dir))
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_jdbc_drivers(state: State<'_, Arc<AppState>>) -> Result<Vec<JdbcDriverInfo>, String> {
|
||||
jdbc::list_jdbc_drivers(state.plugins.root_dir())
|
||||
let root_dir = state.plugins.root_dir().to_path_buf();
|
||||
tauri::async_runtime::spawn_blocking(move || jdbc::list_jdbc_drivers(&root_dir))
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -44,10 +53,16 @@ pub async fn import_jdbc_drivers(
|
||||
state: State<'_, Arc<AppState>>,
|
||||
paths: Vec<String>,
|
||||
) -> Result<Vec<JdbcDriverInfo>, String> {
|
||||
jdbc::import_jdbc_drivers(state.plugins.root_dir(), &paths)
|
||||
let root_dir = state.plugins.root_dir().to_path_buf();
|
||||
tauri::async_runtime::spawn_blocking(move || jdbc::import_jdbc_drivers(&root_dir, &paths))
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_jdbc_driver(state: State<'_, Arc<AppState>>, path: String) -> Result<Vec<JdbcDriverInfo>, String> {
|
||||
jdbc::delete_jdbc_driver(state.plugins.root_dir(), &path)
|
||||
let root_dir = state.plugins.root_dir().to_path_buf();
|
||||
tauri::async_runtime::spawn_blocking(move || jdbc::delete_jdbc_driver(&root_dir, &path))
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
}
|
||||
Reference in new issue
Block a user