diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 0430d777..6c2c7bbb 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -15,7 +15,7 @@ anstream = "0.6.4" anstyle = "1.0.4" anyhow = "1.0" camino = { version = "1.0.4", features = ["serde1"] } -ostree-ext = { version = "0.12", git = "https://github.com/ostreedev/ostree-rs-ext/"} +ostree-ext = { version = "0.12.8" } chrono = { version = "0.4.23", features = ["serde"] } clap = { version= "4.2", features = ["derive"] } clap_mangen = { version = "0.2", optional = true } diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index 2ff8bebd..fbcc6727 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -122,9 +122,11 @@ pub(crate) async fn pull( } pub(crate) async fn cleanup(sysroot: &SysrootLock) -> Result<()> { + // We create clones (just atomic reference bumps) here to move to the thread. let repo = sysroot.repo(); let sysroot = sysroot.sysroot.clone(); ostree_ext::tokio_util::spawn_blocking_cancellable_flatten(move |cancellable| { + let locked_sysroot = &SysrootLock::from_assumed_locked(&sysroot); let cancellable = Some(cancellable); let repo = &repo; let txn = repo.auto_transaction(cancellable)?; @@ -152,6 +154,17 @@ pub(crate) async fn cleanup(sysroot: &SysrootLock) -> Result<()> { } } + let pruned = ostree_container::deploy::prune(locked_sysroot).context("Pruning images")?; + if !pruned.is_empty() { + let size = glib::format_size(pruned.objsize); + println!( + "Pruned images: {} (layers: {}, objsize: {})", + pruned.n_images, pruned.n_layers, size + ); + } else { + tracing::debug!("Nothing to prune"); + } + Ok(()) }) .await @@ -219,7 +232,6 @@ pub(crate) async fn stage( println!(" Version: {version}"); } println!(" Digest: {}", image.manifest_digest); - ostree_container::deploy::remove_undeployed_images(sysroot).context("Pruning images")?; Ok(()) }