@@ -183,7 +183,6 @@ pub struct ImageImporter {
183
183
require_bootable : bool ,
184
184
/// If true, we have ostree v2024.3 or newer.
185
185
ostree_v2024_3 : bool ,
186
- pub ( crate ) proxy_img : OpenedImage ,
187
186
188
187
layer_progress : Option < Sender < ImportProgress > > ,
189
188
layer_byte_progress : Option < tokio:: sync:: watch:: Sender < Option < LayerProgress > > > ,
@@ -241,6 +240,8 @@ pub struct PreparedImport {
241
240
pub layers : Vec < ManifestLayerState > ,
242
241
/// OSTree remote signature verification text, if enabled.
243
242
pub verify_text : Option < String > ,
243
+ /// Our open image reference
244
+ proxy_img : OpenedImage ,
244
245
}
245
246
246
247
impl PreparedImport {
@@ -509,12 +510,10 @@ impl ImageImporter {
509
510
& format ! ( "Fetching {}" , imgref) ,
510
511
) ;
511
512
512
- let proxy_img = proxy. open_image ( & imgref. imgref . to_string ( ) ) . await ?;
513
513
let repo = repo. clone ( ) ;
514
514
Ok ( ImageImporter {
515
515
repo,
516
516
proxy,
517
- proxy_img,
518
517
target_imgref : None ,
519
518
no_imgref : false ,
520
519
ostree_v2024_3 : ostree:: check_version ( 2024 , 3 ) ,
@@ -619,6 +618,7 @@ impl ImageImporter {
619
618
config : ImageConfiguration ,
620
619
previous_state : Option < Box < LayeredImageState > > ,
621
620
previous_imageid : Option < String > ,
621
+ proxy_img : OpenedImage ,
622
622
) -> Result < Box < PreparedImport > > {
623
623
let config_labels = super :: labels_of ( & config) ;
624
624
if self . require_bootable {
@@ -662,6 +662,7 @@ impl ImageImporter {
662
662
ostree_commit_layer : commit_layer,
663
663
layers : remaining_layers,
664
664
verify_text : None ,
665
+ proxy_img,
665
666
} ;
666
667
Ok ( Box :: new ( imp) )
667
668
}
@@ -681,7 +682,12 @@ impl ImageImporter {
681
682
_ => { }
682
683
}
683
684
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 ?;
685
691
let manifest_digest = Digest :: from_str ( & manifest_digest) ?;
686
692
let new_imageid = manifest. config ( ) . digest ( ) ;
687
693
@@ -704,7 +710,7 @@ impl ImageImporter {
704
710
( None , None )
705
711
} ;
706
712
707
- let config = self . proxy . fetch_config ( & self . proxy_img ) . await ?;
713
+ let config = self . proxy . fetch_config ( & proxy_img) . await ?;
708
714
709
715
// If there is a currently fetched image, cache the new pending manifest+config
710
716
// as detached commit metadata, so that future fetches can query it offline.
@@ -724,6 +730,7 @@ impl ImageImporter {
724
730
config,
725
731
previous_state,
726
732
previous_imageid,
733
+ proxy_img,
727
734
) ?;
728
735
Ok ( PrepareResult :: Ready ( imp) )
729
736
}
@@ -756,7 +763,7 @@ impl ImageImporter {
756
763
}
757
764
return Ok ( ( ) ) ;
758
765
} ;
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 ?;
760
767
for layer in import. ostree_layers . iter_mut ( ) {
761
768
if layer. commit . is_some ( ) {
762
769
continue ;
@@ -767,7 +774,7 @@ impl ImageImporter {
767
774
}
768
775
let ( blob, driver, media_type) = fetch_layer (
769
776
& self . proxy ,
770
- & self . proxy_img ,
777
+ & import . proxy_img ,
771
778
& import. manifest ,
772
779
& layer. layer ,
773
780
self . layer_byte_progress . as_ref ( ) ,
@@ -814,7 +821,7 @@ impl ImageImporter {
814
821
}
815
822
let ( blob, driver, media_type) = fetch_layer (
816
823
& self . proxy ,
817
- & self . proxy_img ,
824
+ & import . proxy_img ,
818
825
& import. manifest ,
819
826
& commit_layer. layer ,
820
827
self . layer_byte_progress . as_ref ( ) ,
@@ -874,7 +881,7 @@ impl ImageImporter {
874
881
self . unencapsulate_base ( & mut prep, true , false ) . await ?;
875
882
// TODO change the imageproxy API to ensure this happens automatically when
876
883
// the image reference is dropped
877
- self . proxy . close_image ( & self . proxy_img ) . await ?;
884
+ self . proxy . close_image ( & prep . proxy_img ) . await ?;
878
885
// SAFETY: We know we have a commit
879
886
let ostree_commit = prep. ostree_commit_layer . unwrap ( ) . commit . unwrap ( ) ;
880
887
let image_digest = prep. manifest_digest ;
@@ -899,9 +906,8 @@ impl ImageImporter {
899
906
// First download all layers for the base image (if necessary) - we need the SELinux policy
900
907
// there to label all following layers.
901
908
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 ?;
903
910
let proxy = self . proxy ;
904
- let proxy_img = self . proxy_img ;
905
911
let target_imgref = self . target_imgref . as_ref ( ) . unwrap_or ( & self . imgref ) ;
906
912
let base_commit = import
907
913
. ostree_commit_layer
@@ -935,7 +941,7 @@ impl ImageImporter {
935
941
}
936
942
let ( blob, driver, media_type) = super :: unencapsulate:: fetch_layer (
937
943
& proxy,
938
- & proxy_img,
944
+ & import . proxy_img ,
939
945
& import. manifest ,
940
946
& layer. layer ,
941
947
self . layer_byte_progress . as_ref ( ) ,
@@ -989,7 +995,7 @@ impl ImageImporter {
989
995
990
996
// TODO change the imageproxy API to ensure this happens automatically when
991
997
// the image reference is dropped
992
- proxy. close_image ( & proxy_img) . await ?;
998
+ proxy. close_image ( & import . proxy_img ) . await ?;
993
999
994
1000
// We're done with the proxy, make sure it didn't have any errors.
995
1001
proxy. finalize ( ) . await ?;
0 commit comments