diff --git a/lib/crates/fabro-cli/src/commands/server/record.rs b/lib/crates/fabro-cli/src/commands/server/record.rs index bcc314190..629b7083a 100644 --- a/lib/crates/fabro-cli/src/commands/server/record.rs +++ b/lib/crates/fabro-cli/src/commands/server/record.rs @@ -70,9 +70,8 @@ fn active_server_record_at_path(path: PathBuf) -> Option { pub(crate) fn active_server_record_details(storage_dir: &Path) -> Option { let primary_path = server_record_path(storage_dir); - active_server_record_at_path(primary_path).or_else(|| { - legacy_record_path(storage_dir).and_then(|path| active_server_record_at_path(path)) - }) + active_server_record_at_path(primary_path) + .or_else(|| legacy_record_path(storage_dir).and_then(active_server_record_at_path)) } pub(crate) fn active_server_record(storage_dir: &Path) -> Option { diff --git a/lib/crates/fabro-cli/src/server_client.rs b/lib/crates/fabro-cli/src/server_client.rs index 5fef4636c..e04a0e9fd 100644 --- a/lib/crates/fabro-cli/src/server_client.rs +++ b/lib/crates/fabro-cli/src/server_client.rs @@ -148,19 +148,16 @@ async fn connect_target_api_client( Ok(connect_remote_api_client(api_url, tls.as_ref())?) } user_config::ServerTarget::UnixSocket(path) => { - match connect_unix_socket_api_client(path).await { - Ok(client) => Ok(client), - Err(_) => { - start::ensure_server_running_on_socket( - path, - &runtime.active_config_path, - &runtime.storage_dir, - ) - .with_context(|| { - format!("Failed to start fabro server for {}", path.display()) - })?; - connect_unix_socket_api_client(path).await - } + if let Ok(client) = connect_unix_socket_api_client(path).await { + Ok(client) + } else { + start::ensure_server_running_on_socket( + path, + &runtime.active_config_path, + &runtime.storage_dir, + ) + .with_context(|| format!("Failed to start fabro server for {}", path.display()))?; + connect_unix_socket_api_client(path).await } } } diff --git a/lib/crates/fabro-types/src/settings/mod.rs b/lib/crates/fabro-types/src/settings/mod.rs index bb3285fe4..4b5cb6468 100644 --- a/lib/crates/fabro-types/src/settings/mod.rs +++ b/lib/crates/fabro-types/src/settings/mod.rs @@ -185,8 +185,10 @@ impl Settings { std::env::var_os("FABRO_HOME") .map(|root| PathBuf::from(root).join("storage")) .or_else(|| dirs::home_dir().map(|home| home.join(".fabro"))) - .map(|root| root.join("storage")) - .unwrap_or_else(|| PathBuf::from(".fabro/storage")) + .map_or_else( + || PathBuf::from(".fabro/storage"), + |root| root.join("storage"), + ) }) } } diff --git a/lib/crates/fabro-workflow/src/run_lookup.rs b/lib/crates/fabro-workflow/src/run_lookup.rs index 295746c75..f9acca1e6 100644 --- a/lib/crates/fabro-workflow/src/run_lookup.rs +++ b/lib/crates/fabro-workflow/src/run_lookup.rs @@ -3,9 +3,9 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, bail}; use chrono::{DateTime, Utc}; -use fabro_config::{Home, Storage}; +use fabro_config::Storage; use fabro_store::{Database, RunSummary}; -use fabro_types::RunId; +use fabro_types::{RunId, Settings}; use serde::Serialize; use crate::operations::make_run_dir; @@ -132,7 +132,7 @@ pub fn scratch_base(storage_dir: &Path) -> PathBuf { } pub fn default_scratch_base() -> PathBuf { - scratch_base(Home::from_env().root()) + scratch_base(&Settings::default().storage_dir()) } fn scan_orphan_runs(base: &Path) -> Result> {