Skip to content

Commit

Permalink
cli: wipe_ostree in spawn_blocking
Browse files Browse the repository at this point in the history
Solves #778

Signed-off-by: Omer Tuchfeld <[email protected]>
  • Loading branch information
omertuc committed Sep 6, 2024
1 parent 1ba8d1e commit ae54070
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}
},
Expand Down
11 changes: 7 additions & 4 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down

0 comments on commit ae54070

Please sign in to comment.