>(path: Option, error: Error) -> Result {
+ pub async fn init>(
+ path: Option,
+ disk_guid: Option>,
+ error: Error,
+ ) -> Result {
let cfg = DiagnosticContextConfig::load(path).await?;
let (shutdown, _) = tokio::sync::broadcast::channel(1);
Ok(Self(Arc::new(DiagnosticContextSeed {
bind_rpc: cfg.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()),
+ datadir: cfg.datadir().to_owned(),
shutdown,
+ disk_guid,
error: Arc::new(error.into()),
- zfs_pool_name: Arc::new(cfg.zfs_pool_name().to_owned()),
})))
}
}
diff --git a/appmgr/src/context/rpc.rs b/appmgr/src/context/rpc.rs
index d64d79b39..1048611f5 100644
--- a/appmgr/src/context/rpc.rs
+++ b/appmgr/src/context/rpc.rs
@@ -43,7 +43,6 @@ pub struct RpcContextConfig {
pub tor_control: Option,
pub tor_socks: Option,
pub revision_cache_size: Option,
- pub zfs_pool_name: Option,
pub datadir: Option,
pub log_server: Option,
}
@@ -62,17 +61,10 @@ impl RpcContextConfig {
Ok(Self::default())
}
}
- pub fn zfs_pool_name(&self) -> &str {
- self.zfs_pool_name
- .as_ref()
- .map(|s| s.as_str())
- .unwrap_or("embassy-data")
- }
- pub fn datadir(&self) -> Cow<'_, Path> {
+ pub fn datadir(&self) -> &Path {
self.datadir
- .as_ref()
- .map(|a| Cow::Borrowed(a.as_path()))
- .unwrap_or_else(|| Cow::Owned(Path::new("/").join(self.zfs_pool_name())))
+ .as_deref()
+ .unwrap_or_else(|| Path::new("/embassy-data"))
}
pub async fn db(&self, secret_store: &SqlitePool) -> Result {
let db_path = self.datadir().join("main").join("embassy.db");
@@ -115,7 +107,7 @@ pub struct RpcContextSeed {
pub bind_ws: SocketAddr,
pub bind_static: SocketAddr,
pub datadir: PathBuf,
- pub zfs_pool_name: Arc,
+ pub disk_guid: Arc,
pub db: PatchDb,
pub secret_store: SqlitePool,
pub docker: Docker,
@@ -136,7 +128,10 @@ pub struct RpcContextSeed {
pub struct RpcContext(Arc);
impl RpcContext {
#[instrument(skip(cfg_path))]
- pub async fn init>(cfg_path: Option) -> Result {
+ pub async fn init>(
+ cfg_path: Option,
+ disk_guid: Arc,
+ ) -> Result {
let base = RpcContextConfig::load(cfg_path).await?;
let log_epoch = Arc::new(AtomicU64::new(rand::random()));
let logger = EmbassyLogger::init(log_epoch.clone(), base.log_server.clone(), false);
@@ -167,7 +162,7 @@ impl RpcContext {
bind_ws: base.bind_ws.unwrap_or(([127, 0, 0, 1], 5960).into()),
bind_static: base.bind_static.unwrap_or(([127, 0, 0, 1], 5961).into()),
datadir: base.datadir().to_path_buf(),
- zfs_pool_name: Arc::new(base.zfs_pool_name().to_owned()),
+ disk_guid,
db,
secret_store,
docker,
diff --git a/appmgr/src/context/setup.rs b/appmgr/src/context/setup.rs
index b0d47f3a4..15fcf3cee 100644
--- a/appmgr/src/context/setup.rs
+++ b/appmgr/src/context/setup.rs
@@ -30,7 +30,6 @@ use crate::{Error, ResultExt};
#[serde(rename_all = "kebab-case")]
pub struct SetupContextConfig {
pub bind_rpc: Option,
- pub zfs_pool_name: Option,
pub datadir: Option,
}
impl SetupContextConfig {
@@ -49,17 +48,10 @@ impl SetupContextConfig {
Ok(Self::default())
}
}
- pub fn zfs_pool_name(&self) -> &str {
- self.zfs_pool_name
- .as_ref()
- .map(|s| s.as_str())
- .unwrap_or("embassy-data")
- }
- pub fn datadir(&self) -> Cow<'_, Path> {
+ pub fn datadir(&self) -> &Path {
self.datadir
- .as_ref()
- .map(|a| Cow::Borrowed(a.as_path()))
- .unwrap_or_else(|| Cow::Owned(Path::new("/").join(self.zfs_pool_name())))
+ .as_deref()
+ .unwrap_or_else(|| Path::new("/embassy-data"))
}
}
@@ -67,7 +59,6 @@ pub struct SetupContextSeed {
pub bind_rpc: SocketAddr,
pub shutdown: Sender<()>,
pub datadir: PathBuf,
- pub zfs_pool_name: Arc,
pub selected_v2_drive: RwLock