diff --git a/mediarepo-api/src/tauri_plugin/commands/daemon.rs b/mediarepo-api/src/tauri_plugin/commands/daemon.rs index 9a6d658..bf96dd7 100644 --- a/mediarepo-api/src/tauri_plugin/commands/daemon.rs +++ b/mediarepo-api/src/tauri_plugin/commands/daemon.rs @@ -1,6 +1,7 @@ -use crate::client_api::ApiClient; use crate::tauri_plugin::commands::AppAccess; use crate::tauri_plugin::error::PluginResult; +use rmp_ipc::prelude::IPCResult; +use rmp_ipc::IPCBuilder; #[tauri::command] pub async fn init_repository(app_state: AppAccess<'_>, repo_path: String) -> PluginResult<()> { @@ -28,9 +29,18 @@ pub async fn stop_daemon(app_state: AppAccess<'_>, repo_path: String) -> PluginR #[tauri::command] pub async fn check_daemon_running(address: String) -> PluginResult { - if let Ok(api_client) = ApiClient::connect(&address).await { - Ok(api_client.info().await.is_ok()) - } else { - Ok(false) - } + let connect_result = try_connect_daemon(address).await; + + Ok(connect_result.is_ok()) +} + +async fn try_connect_daemon(address: String) -> IPCResult<()> { + let ctx = IPCBuilder::new().address(address).build_client().await?; + ctx.emitter + .emit("info", ()) + .await? + .await_reply(&ctx) + .await?; + ctx.stop().await?; + Ok(()) }