@@ -263,6 +263,8 @@ async fn stage(
263
263
if let Some ( imgref) = ostree_imgref. as_ref ( ) {
264
264
println ! ( "Queued for next boot: {imgref}" ) ;
265
265
}
266
+ ostree_container:: deploy:: remove_undeployed_images ( sysroot) . context ( "Pruning images" ) ?;
267
+
266
268
Ok ( ( ) )
267
269
}
268
270
@@ -368,8 +370,6 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
368
370
let repo = & sysroot. repo ( ) ;
369
371
let booted_deployment = & sysroot. require_booted_deployment ( ) ?;
370
372
let ( _deployments, host) = crate :: status:: get_status ( sysroot, Some ( booted_deployment) ) ?;
371
- // SAFETY: There must be a status if we have a booted deployment
372
- let status = host. status . unwrap ( ) ;
373
373
374
374
let transport = ostree_container:: Transport :: try_from ( opts. transport . as_str ( ) ) ?;
375
375
let imgref = ostree_container:: ImageReference {
@@ -399,17 +399,12 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
399
399
let fetched = pull ( repo, & target, opts. quiet ) . await ?;
400
400
401
401
if !opts. retain {
402
- // By default, we prune the previous ostree ref or container image
402
+ // By default, we prune the previous ostree ref so it will go away after later upgrades
403
403
if let Some ( booted_origin) = booted_deployment. origin ( ) {
404
404
if let Some ( ostree_ref) = booted_origin. optional_string ( "origin" , "refspec" ) ? {
405
405
let ( remote, ostree_ref) =
406
406
ostree:: parse_refspec ( & ostree_ref) . context ( "Failed to parse ostree ref" ) ?;
407
407
repo. set_ref_immediate ( remote. as_deref ( ) , & ostree_ref, None , cancellable) ?;
408
- } else if let Some ( booted_image) = status. booted . as_ref ( ) . and_then ( |b| b. image . as_ref ( ) )
409
- {
410
- let imgref = OstreeImageReference :: from ( booted_image. image . clone ( ) ) ;
411
- ostree_container:: store:: remove_image ( repo, & imgref. imgref ) ?;
412
- let _nlayers: u32 = ostree_container:: store:: gc_image_layers ( repo) ?;
413
408
}
414
409
}
415
410
}
0 commit comments