fix(storage): align workflow scratch defaults with settings

Full workspace verification exposed one real mismatch after the socket and
storage split: workflow default scratch lookup still derived from ~/.fabro
instead of the new storage root. Keep the helper aligned with Settings defaults
and fold in the small clippy-driven cleanups in the related server path code.
This commit is contained in:
Bryan Helmkamp 2026-04-06 12:21:54 -04:00
parent cb58b18385
commit cd392b29c7
No known key found for this signature in database
4 changed files with 19 additions and 21 deletions

View file

@ -70,9 +70,8 @@ fn active_server_record_at_path(path: PathBuf) -> Option<ActiveServerRecord> {
pub(crate) fn active_server_record_details(storage_dir: &Path) -> Option<ActiveServerRecord> {
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<ServerRecord> {

View file

@ -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
}
}
}

View file

@ -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"),
)
})
}
}

View file

@ -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<Vec<RunInfo>> {