Add daemon path fallback discovery check

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

@ -11,8 +11,9 @@ use tokio::time::Instant;
use crate::client_api::ApiClient; use crate::client_api::ApiClient;
use crate::daemon_management::cli::DaemonCli; use crate::daemon_management::cli::DaemonCli;
use crate::daemon_management::find_daemon_executable;
use crate::tauri_plugin::error::{PluginError, PluginResult}; use crate::tauri_plugin::error::{PluginError, PluginResult};
use crate::tauri_plugin::settings::{load_settings, Repository, Settings}; use crate::tauri_plugin::settings::{load_settings, save_settings, Repository, Settings};
pub struct ApiState { pub struct ApiState {
inner: Arc<RwLock<Option<ApiClient>>>, inner: Arc<RwLock<Option<ApiClient>>>,
@ -180,7 +181,12 @@ impl AppState {
/// Returns the daemon cli client /// Returns the daemon cli client
pub async fn get_daemon_cli(&self, repo_path: String) -> PluginResult<DaemonCli> { pub async fn get_daemon_cli(&self, repo_path: String) -> PluginResult<DaemonCli> {
let settings = self.settings.read().await; let mut settings = self.settings.write().await;
if settings.daemon_path.is_none() {
settings.daemon_path =
find_daemon_executable().map(|p| p.to_string_lossy().to_string());
save_settings(&settings)?;
}
let path = settings let path = settings
.daemon_path .daemon_path
.clone() .clone()

Loading…
Cancel
Save