Add daemon discovery to has_executable check

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 2 years ago
parent 2cb7e9cb9b
commit aa568a9365

@ -1,5 +1,7 @@
use crate::daemon_management::find_daemon_executable;
use crate::tauri_plugin::commands::AppAccess;
use crate::tauri_plugin::error::PluginResult;
use crate::tauri_plugin::settings::save_settings;
use bromine::prelude::{IPCError, IPCResult};
use bromine::IPCBuilder;
use std::io::ErrorKind;
@ -8,7 +10,12 @@ use tokio::net::TcpListener;
#[tauri::command]
pub async fn has_executable(app_state: AppAccess<'_>) -> PluginResult<bool> {
let settings = app_state.settings.read().await;
let mut settings = app_state.settings.write().await;
if settings.daemon_path.is_none() {
settings.daemon_path = find_daemon_executable().map(|e| e.to_string_lossy().to_string());
save_settings(&settings)?;
}
Ok(settings.daemon_path.is_some())
}

Loading…
Cancel
Save