From ae540705e398304ba0375c9a05476f2ec565bf12 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Fri, 6 Sep 2024 19:12:26 +0200 Subject: [PATCH] cli: wipe_ostree in spawn_blocking Solves #778 Signed-off-by: Omer Tuchfeld --- lib/src/cli.rs | 3 +-- lib/src/deploy.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index c5bf5a1e3..76b4b88fb 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -21,7 +21,6 @@ use ostree_ext::keyfileext::KeyFileExt; use ostree_ext::ostree; use schemars::schema_for; -use crate::deploy::wipe_ostree; use crate::deploy::RequiredHostSpec; use crate::lints; use crate::spec::Host; @@ -929,7 +928,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { StateOpts::WipeOstree => { let sysroot = ostree::Sysroot::new_default(); sysroot.load(gio::Cancellable::NONE)?; - wipe_ostree(&sysroot).await?; + crate::deploy::wipe_ostree(sysroot).await?; Ok(()) } }, diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index 67a5794e8..cd1ef419d 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -288,10 +288,13 @@ pub(crate) async fn prune_container_store(sysroot: &Storage) -> Result<()> { Ok(()) } -pub(crate) async fn wipe_ostree(sysroot: &Sysroot) -> Result<()> { - sysroot - .write_deployments(&[], gio::Cancellable::NONE) - .context("removing deployments")?; +pub(crate) async fn wipe_ostree(sysroot: Sysroot) -> Result<()> { + tokio::task::spawn_blocking(move || { + sysroot + .write_deployments(&[], gio::Cancellable::NONE) + .context("removing deployments") + }) + .await??; Ok(()) }