fix deadlock

This commit is contained in:
Aiden McClelland
2024-03-07 16:43:13 -07:00
parent 2e7c3bf789
commit 8665342edf
4 changed files with 9 additions and 8 deletions

View File

@@ -97,6 +97,7 @@ pub async fn recover_full_embassy(
let db = ctx.db().await?;
db.put(&ROOT, &Database::init(&os_backup.account)?).await?;
drop(db);
init(&ctx.config).await?;

View File

@@ -1,4 +1,5 @@
use std::collections::BTreeMap;
use std::future::Future;
use std::marker::PhantomData;
use std::panic::UnwindSafe;
use std::str::FromStr;
@@ -30,19 +31,17 @@ where
patch_db::value::from_value(value).with_kind(ErrorKind::Deserialization)
}
#[async_trait::async_trait]
pub trait PatchDbExt {
async fn peek(&self) -> DatabaseModel;
async fn mutate<U: UnwindSafe + Send>(
fn peek(&self) -> impl Future<Output = DatabaseModel> + Send;
fn mutate<U: UnwindSafe + Send>(
&self,
f: impl FnOnce(&mut DatabaseModel) -> Result<U, Error> + UnwindSafe + Send,
) -> Result<U, Error>;
async fn map_mutate(
) -> impl Future<Output = Result<U, Error>> + Send;
fn map_mutate(
&self,
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 {
async fn peek(&self) -> DatabaseModel {
DatabaseModel::from(self.dump(&ROOT).await.value)

View File

@@ -60,7 +60,7 @@ pub(self) async fn default_mount_command(
cmd.arg(source.as_ref());
}
cmd.arg(mountpoint.as_ref());
Ok(dbg!(cmd))
Ok(cmd)
}
pub(self) async fn default_mount_impl(

View File

@@ -419,6 +419,7 @@ async fn fresh_setup(
let account = AccountInfo::new(embassy_password, root_ca_start_time().await?)?;
let db = ctx.db().await?;
db.put(&ROOT, &Database::init(&account)?).await?;
drop(db);
init(&ctx.config).await?;
Ok((
account.hostname,