From 443e3135663ace05e5fe20883b3cb1fbba354d28 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 27 Sep 2021 14:00:34 -0600 Subject: [PATCH] agressive locking --- appmgr/src/diagnostic.rs | 9 +++++++-- appmgr/src/status/mod.rs | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/appmgr/src/diagnostic.rs b/appmgr/src/diagnostic.rs index d71454ff2..aec5d36ca 100644 --- a/appmgr/src/diagnostic.rs +++ b/appmgr/src/diagnostic.rs @@ -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(()) } diff --git a/appmgr/src/status/mod.rs b/appmgr/src/status/mod.rs index e29945a75..0c3e45e60 100644 --- a/appmgr/src/status/mod.rs +++ b/appmgr/src/status/mod.rs @@ -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/. 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()