@@ -183,7 +183,6 @@ pub struct ImageImporter {
183183 require_bootable : bool ,
184184 /// If true, we have ostree v2024.3 or newer.
185185 ostree_v2024_3 : bool ,
186- pub ( crate ) proxy_img : OpenedImage ,
187186
188187 layer_progress : Option < Sender < ImportProgress > > ,
189188 layer_byte_progress : Option < tokio:: sync:: watch:: Sender < Option < LayerProgress > > > ,
@@ -241,6 +240,8 @@ pub struct PreparedImport {
241240 pub layers : Vec < ManifestLayerState > ,
242241 /// OSTree remote signature verification text, if enabled.
243242 pub verify_text : Option < String > ,
243+ /// Our open image reference
244+ proxy_img : OpenedImage ,
244245}
245246
246247impl PreparedImport {
@@ -509,12 +510,10 @@ impl ImageImporter {
509510 & format ! ( "Fetching {}" , imgref) ,
510511 ) ;
511512
512- let proxy_img = proxy. open_image ( & imgref. imgref . to_string ( ) ) . await ?;
513513 let repo = repo. clone ( ) ;
514514 Ok ( ImageImporter {
515515 repo,
516516 proxy,
517- proxy_img,
518517 target_imgref : None ,
519518 no_imgref : false ,
520519 ostree_v2024_3 : ostree:: check_version ( 2024 , 3 ) ,
@@ -619,6 +618,7 @@ impl ImageImporter {
619618 config : ImageConfiguration ,
620619 previous_state : Option < Box < LayeredImageState > > ,
621620 previous_imageid : Option < String > ,
621+ proxy_img : OpenedImage ,
622622 ) -> Result < Box < PreparedImport > > {
623623 let config_labels = super :: labels_of ( & config) ;
624624 if self . require_bootable {
@@ -662,6 +662,7 @@ impl ImageImporter {
662662 ostree_commit_layer : commit_layer,
663663 layers : remaining_layers,
664664 verify_text : None ,
665+ proxy_img,
665666 } ;
666667 Ok ( Box :: new ( imp) )
667668 }
@@ -681,7 +682,12 @@ impl ImageImporter {
681682 _ => { }
682683 }
683684
684- let ( manifest_digest, manifest) = self . proxy . fetch_manifest ( & self . proxy_img ) . await ?;
685+ let proxy_img = self
686+ . proxy
687+ . open_image ( & self . imgref . imgref . to_string ( ) )
688+ . await ?;
689+
690+ let ( manifest_digest, manifest) = self . proxy . fetch_manifest ( & proxy_img) . await ?;
685691 let manifest_digest = Digest :: from_str ( & manifest_digest) ?;
686692 let new_imageid = manifest. config ( ) . digest ( ) ;
687693
@@ -704,7 +710,7 @@ impl ImageImporter {
704710 ( None , None )
705711 } ;
706712
707- let config = self . proxy . fetch_config ( & self . proxy_img ) . await ?;
713+ let config = self . proxy . fetch_config ( & proxy_img) . await ?;
708714
709715 // If there is a currently fetched image, cache the new pending manifest+config
710716 // as detached commit metadata, so that future fetches can query it offline.
@@ -724,6 +730,7 @@ impl ImageImporter {
724730 config,
725731 previous_state,
726732 previous_imageid,
733+ proxy_img,
727734 ) ?;
728735 Ok ( PrepareResult :: Ready ( imp) )
729736 }
@@ -756,7 +763,7 @@ impl ImageImporter {
756763 }
757764 return Ok ( ( ) ) ;
758765 } ;
759- let des_layers = self . proxy . get_layer_info ( & self . proxy_img ) . await ?;
766+ let des_layers = self . proxy . get_layer_info ( & import . proxy_img ) . await ?;
760767 for layer in import. ostree_layers . iter_mut ( ) {
761768 if layer. commit . is_some ( ) {
762769 continue ;
@@ -767,7 +774,7 @@ impl ImageImporter {
767774 }
768775 let ( blob, driver, media_type) = fetch_layer (
769776 & self . proxy ,
770- & self . proxy_img ,
777+ & import . proxy_img ,
771778 & import. manifest ,
772779 & layer. layer ,
773780 self . layer_byte_progress . as_ref ( ) ,
@@ -814,7 +821,7 @@ impl ImageImporter {
814821 }
815822 let ( blob, driver, media_type) = fetch_layer (
816823 & self . proxy ,
817- & self . proxy_img ,
824+ & import . proxy_img ,
818825 & import. manifest ,
819826 & commit_layer. layer ,
820827 self . layer_byte_progress . as_ref ( ) ,
@@ -874,7 +881,7 @@ impl ImageImporter {
874881 self . unencapsulate_base ( & mut prep, true , false ) . await ?;
875882 // TODO change the imageproxy API to ensure this happens automatically when
876883 // the image reference is dropped
877- self . proxy . close_image ( & self . proxy_img ) . await ?;
884+ self . proxy . close_image ( & prep . proxy_img ) . await ?;
878885 // SAFETY: We know we have a commit
879886 let ostree_commit = prep. ostree_commit_layer . unwrap ( ) . commit . unwrap ( ) ;
880887 let image_digest = prep. manifest_digest ;
@@ -899,9 +906,8 @@ impl ImageImporter {
899906 // First download all layers for the base image (if necessary) - we need the SELinux policy
900907 // there to label all following layers.
901908 self . unencapsulate_base ( & mut import, false , true ) . await ?;
902- let des_layers = self . proxy . get_layer_info ( & self . proxy_img ) . await ?;
909+ let des_layers = self . proxy . get_layer_info ( & import . proxy_img ) . await ?;
903910 let proxy = self . proxy ;
904- let proxy_img = self . proxy_img ;
905911 let target_imgref = self . target_imgref . as_ref ( ) . unwrap_or ( & self . imgref ) ;
906912 let base_commit = import
907913 . ostree_commit_layer
@@ -935,7 +941,7 @@ impl ImageImporter {
935941 }
936942 let ( blob, driver, media_type) = super :: unencapsulate:: fetch_layer (
937943 & proxy,
938- & proxy_img,
944+ & import . proxy_img ,
939945 & import. manifest ,
940946 & layer. layer ,
941947 self . layer_byte_progress . as_ref ( ) ,
@@ -989,7 +995,7 @@ impl ImageImporter {
989995
990996 // TODO change the imageproxy API to ensure this happens automatically when
991997 // the image reference is dropped
992- proxy. close_image ( & proxy_img) . await ?;
998+ proxy. close_image ( & import . proxy_img ) . await ?;
993999
9941000 // We're done with the proxy, make sure it didn't have any errors.
9951001 proxy. finalize ( ) . await ?;
0 commit comments