mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
fix deadlock
This commit is contained in:
@@ -97,6 +97,7 @@ pub async fn recover_full_embassy(
|
|||||||
|
|
||||||
let db = ctx.db().await?;
|
let db = ctx.db().await?;
|
||||||
db.put(&ROOT, &Database::init(&os_backup.account)?).await?;
|
db.put(&ROOT, &Database::init(&os_backup.account)?).await?;
|
||||||
|
drop(db);
|
||||||
|
|
||||||
init(&ctx.config).await?;
|
init(&ctx.config).await?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::future::Future;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::panic::UnwindSafe;
|
use std::panic::UnwindSafe;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -30,19 +31,17 @@ where
|
|||||||
patch_db::value::from_value(value).with_kind(ErrorKind::Deserialization)
|
patch_db::value::from_value(value).with_kind(ErrorKind::Deserialization)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
pub trait PatchDbExt {
|
pub trait PatchDbExt {
|
||||||
async fn peek(&self) -> DatabaseModel;
|
fn peek(&self) -> impl Future<Output = DatabaseModel> + Send;
|
||||||
async fn mutate<U: UnwindSafe + Send>(
|
fn mutate<U: UnwindSafe + Send>(
|
||||||
&self,
|
&self,
|
||||||
f: impl FnOnce(&mut DatabaseModel) -> Result<U, Error> + UnwindSafe + Send,
|
f: impl FnOnce(&mut DatabaseModel) -> Result<U, Error> + UnwindSafe + Send,
|
||||||
) -> Result<U, Error>;
|
) -> impl Future<Output = Result<U, Error>> + Send;
|
||||||
async fn map_mutate(
|
fn map_mutate(
|
||||||
&self,
|
&self,
|
||||||
f: impl FnOnce(DatabaseModel) -> Result<DatabaseModel, Error> + UnwindSafe + Send,
|
f: impl FnOnce(DatabaseModel) -> Result<DatabaseModel, Error> + UnwindSafe + Send,
|
||||||
) -> Result<DatabaseModel, Error>;
|
) -> impl Future<Output = Result<DatabaseModel, Error>> + Send;
|
||||||
}
|
}
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl PatchDbExt for PatchDb {
|
impl PatchDbExt for PatchDb {
|
||||||
async fn peek(&self) -> DatabaseModel {
|
async fn peek(&self) -> DatabaseModel {
|
||||||
DatabaseModel::from(self.dump(&ROOT).await.value)
|
DatabaseModel::from(self.dump(&ROOT).await.value)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pub(self) async fn default_mount_command(
|
|||||||
cmd.arg(source.as_ref());
|
cmd.arg(source.as_ref());
|
||||||
}
|
}
|
||||||
cmd.arg(mountpoint.as_ref());
|
cmd.arg(mountpoint.as_ref());
|
||||||
Ok(dbg!(cmd))
|
Ok(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(self) async fn default_mount_impl(
|
pub(self) async fn default_mount_impl(
|
||||||
|
|||||||
@@ -419,6 +419,7 @@ async fn fresh_setup(
|
|||||||
let account = AccountInfo::new(embassy_password, root_ca_start_time().await?)?;
|
let account = AccountInfo::new(embassy_password, root_ca_start_time().await?)?;
|
||||||
let db = ctx.db().await?;
|
let db = ctx.db().await?;
|
||||||
db.put(&ROOT, &Database::init(&account)?).await?;
|
db.put(&ROOT, &Database::init(&account)?).await?;
|
||||||
|
drop(db);
|
||||||
init(&ctx.config).await?;
|
init(&ctx.config).await?;
|
||||||
Ok((
|
Ok((
|
||||||
account.hostname,
|
account.hostname,
|
||||||
|
|||||||
Reference in New Issue
Block a user