@@ -380,6 +380,98 @@ pub(crate) async fn prepare_for_pull(
380380 Ok ( PreparedPullResult :: Ready ( Box :: new ( prepared_image) ) )
381381}
382382
383+ /// Unified approach: First pull with podman to containers-storage, then prepare from containers-storage
384+ pub ( crate ) async fn prepare_for_pull_unified (
385+ repo : & ostree:: Repo ,
386+ imgref : & ImageReference ,
387+ target_imgref : Option < & OstreeImageReference > ,
388+ store : & Storage ,
389+ ) -> Result < PreparedPullResult > {
390+ // Ensure bootc storage is properly initialized before using unified storage
391+ let _imgstore = store. get_ensure_imgstore ( ) ?;
392+
393+ // First, pull the image using podman with unified storage
394+ crate :: podman:: pull_image_unified ( & format ! ( "{imgref:#}" ) ) . await ?;
395+
396+ // Now create a containers-storage reference to the pulled image
397+ let containers_storage_imgref = ImageReference {
398+ transport : "containers-storage" . to_string ( ) ,
399+ image : imgref. image . clone ( ) ,
400+ signature : imgref. signature . clone ( ) ,
401+ } ;
402+ let ostree_imgref = & OstreeImageReference :: from ( containers_storage_imgref) ;
403+
404+ // Use the standard preparation flow but reading from containers-storage
405+ let mut imp = new_importer ( repo, ostree_imgref) . await ?;
406+ if let Some ( target) = target_imgref {
407+ imp. set_target ( target) ;
408+ }
409+ let prep = match imp. prepare ( ) . await ? {
410+ PrepareResult :: AlreadyPresent ( c) => {
411+ println ! ( "No changes in {imgref:#} => {}" , c. manifest_digest) ;
412+ return Ok ( PreparedPullResult :: AlreadyPresent ( Box :: new ( ( * c) . into ( ) ) ) ) ;
413+ }
414+ PrepareResult :: Ready ( p) => p,
415+ } ;
416+ check_bootc_label ( & prep. config ) ;
417+ if let Some ( warning) = prep. deprecated_warning ( ) {
418+ ostree_ext:: cli:: print_deprecated_warning ( warning) . await ;
419+ }
420+ ostree_ext:: cli:: print_layer_status ( & prep) ;
421+ let layers_to_fetch = prep. layers_to_fetch ( ) . collect :: < Result < Vec < _ > > > ( ) ?;
422+
423+ let prepared_image = PreparedImportMeta {
424+ imp,
425+ n_layers_to_fetch : layers_to_fetch. len ( ) ,
426+ layers_total : prep. all_layers ( ) . count ( ) ,
427+ bytes_to_fetch : layers_to_fetch. iter ( ) . map ( |( l, _) | l. layer . size ( ) ) . sum ( ) ,
428+ bytes_total : prep. all_layers ( ) . map ( |l| l. layer . size ( ) ) . sum ( ) ,
429+ digest : prep. manifest_digest . clone ( ) ,
430+ prep,
431+ } ;
432+
433+ Ok ( PreparedPullResult :: Ready ( Box :: new ( prepared_image) ) )
434+ }
435+
436+ /// Unified pull: Use podman to pull to containers-storage, then read from there
437+ pub ( crate ) async fn pull_unified (
438+ repo : & ostree:: Repo ,
439+ imgref : & ImageReference ,
440+ target_imgref : Option < & OstreeImageReference > ,
441+ quiet : bool ,
442+ prog : ProgressWriter ,
443+ store : & Storage ,
444+ ) -> Result < Box < ImageState > > {
445+ match prepare_for_pull_unified ( repo, imgref, target_imgref, store) . await ? {
446+ PreparedPullResult :: AlreadyPresent ( existing) => {
447+ // Log that the image was already present (Debug level since it's not actionable)
448+ const IMAGE_ALREADY_PRESENT_ID : & str = "5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9" ;
449+ tracing:: debug!(
450+ message_id = IMAGE_ALREADY_PRESENT_ID ,
451+ bootc. image. reference = & imgref. image,
452+ bootc. image. transport = & imgref. transport,
453+ bootc. status = "already_present" ,
454+ "Image already present: {}" ,
455+ imgref
456+ ) ;
457+ Ok ( existing)
458+ }
459+ PreparedPullResult :: Ready ( prepared_image_meta) => {
460+ // Log that we're pulling a new image
461+ const PULLING_NEW_IMAGE_ID : & str = "6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0" ;
462+ tracing:: info!(
463+ message_id = PULLING_NEW_IMAGE_ID ,
464+ bootc. image. reference = & imgref. image,
465+ bootc. image. transport = & imgref. transport,
466+ bootc. status = "pulling_new" ,
467+ "Pulling new image: {}" ,
468+ imgref
469+ ) ;
470+ pull_from_prepared ( imgref, quiet, prog, * prepared_image_meta) . await
471+ }
472+ }
473+ }
474+
383475#[ context( "Pulling" ) ]
384476pub ( crate ) async fn pull_from_prepared (
385477 imgref : & ImageReference ,
0 commit comments