agressive locking

This commit is contained in:
Aiden McClelland
2021-09-27 14:00:34 -06:00
committed by Aiden McClelland
parent e3d8861199
commit 443e313566
2 changed files with 11 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
use std::path::Path;
use std::sync::Arc;
use rpc_toolkit::command;
@@ -55,6 +56,10 @@ pub fn restart(#[context] ctx: DiagnosticContext) -> Result<(), Error> {
}
#[command(rename = "forget-disk", display(display_none))]
pub fn forget_disk(#[context] ctx: DiagnosticContext) -> Result<(), Error> {
todo!()
pub async fn forget_disk() -> Result<(), Error> {
let disk_guid = Path::new("/embassy-os/disk.guid");
if tokio::fs::metadata(disk_guid).await.is_ok() {
tokio::fs::remove_file(disk_guid).await?;
}
Ok(())
}

View File

@@ -35,10 +35,10 @@ pub async fn synchronize_all(ctx: &RpcContext) -> Result<(), Error> {
// this locks all of package data to solve a deadlock issue below. As of the writing of this comment, it
// hangs during the `check` operation on /package-data/<id>. There is another daemon loop somewhere that
// is likely iterating through packages in a different order.
// crate::db::DatabaseModel::new()
// .package_data()
// .lock(&mut db)
// .await;
crate::db::DatabaseModel::new()
.package_data()
.lock(&mut db, true)
.await;
// Without the above lock, the below check operation will deadlock
let (mut status, manager) = if let Some(installed) = crate::db::DatabaseModel::new()