@@ -750,25 +750,7 @@ pub(crate) async fn update_from_dist(
750
750
}
751
751
}
752
752
753
- let res = update_from_dist_ (
754
- opts. dl_cfg ,
755
- opts. update_hash ,
756
- opts. desc ,
757
- match opts. exists {
758
- true => None ,
759
- false => Some ( opts. profile ) ,
760
- } ,
761
- prefix,
762
- opts. force ,
763
- opts. allow_downgrade ,
764
- opts. old_date_version
765
- . as_ref ( )
766
- . map ( |( date, _) | date. as_str ( ) ) ,
767
- opts. components ,
768
- opts. targets ,
769
- )
770
- . await ;
771
-
753
+ let res = update_from_dist_ ( prefix, opts) . await ;
772
754
// Don't leave behind an empty / broken installation directory
773
755
if res. is_err ( ) && fresh_install {
774
756
// FIXME Ignoring cascading errors
@@ -779,29 +761,21 @@ pub(crate) async fn update_from_dist(
779
761
}
780
762
781
763
async fn update_from_dist_ (
782
- download : DownloadCfg < ' _ > ,
783
- update_hash : Option < & Path > ,
784
- toolchain : & ToolchainDesc ,
785
- profile : Option < Profile > ,
786
764
prefix : & InstallPrefix ,
787
- force_update : bool ,
788
- allow_downgrade : bool ,
789
- old_date : Option < & str > ,
790
- components : & [ & str ] ,
791
- targets : & [ & str ] ,
765
+ opts : & DistOptions < ' _ > ,
792
766
) -> Result < Option < String > > {
793
- let mut toolchain = toolchain. clone ( ) ;
794
767
let mut fetched = String :: new ( ) ;
795
768
let mut first_err = None ;
796
- let backtrack = toolchain . channel == "nightly" && toolchain . date . is_none ( ) ;
769
+ let backtrack = opts . desc . channel == "nightly" && opts . desc . date . is_none ( ) ;
797
770
// We want to limit backtracking if we do not already have a toolchain
798
- let mut backtrack_limit: Option < i32 > = if toolchain . date . is_some ( ) {
771
+ let mut backtrack_limit: Option < i32 > = if opts . desc . date . is_some ( ) {
799
772
None
800
773
} else {
801
774
// We limit the backtracking to 21 days by default (half a release cycle).
802
775
// The limit of 21 days is an arbitrary selection, so we let the user override it.
803
776
const BACKTRACK_LIMIT_DEFAULT : i32 = 21 ;
804
- let provided = download
777
+ let provided = opts
778
+ . dl_cfg
805
779
. process
806
780
. var ( "RUSTUP_BACKTRACK_LIMIT" )
807
781
. ok ( )
@@ -820,30 +794,36 @@ async fn update_from_dist_(
820
794
// We could arguably use the date of the first rustup release here, but that would break a
821
795
// bunch of the tests, which (inexplicably) use 2015-01-01 as their manifest dates.
822
796
let first_manifest = date_from_manifest_date ( "2014-12-20" ) . unwrap ( ) ;
823
- let old_manifest = old_date
824
- . and_then ( date_from_manifest_date)
797
+ let old_manifest = opts
798
+ . old_date_version
799
+ . as_ref ( )
800
+ . and_then ( |( d, _) | date_from_manifest_date ( d) )
825
801
. unwrap_or ( first_manifest) ;
826
- let last_manifest = if allow_downgrade {
802
+ let last_manifest = if opts . allow_downgrade {
827
803
first_manifest
828
804
} else {
829
805
old_manifest
830
806
} ;
831
807
832
808
let current_manifest = {
833
- let manifestation = Manifestation :: open ( prefix. clone ( ) , toolchain . target . clone ( ) ) ?;
809
+ let manifestation = Manifestation :: open ( prefix. clone ( ) , opts . desc . target . clone ( ) ) ?;
834
810
manifestation. load_manifest ( ) ?
835
811
} ;
836
812
813
+ let mut toolchain = opts. desc . clone ( ) ;
837
814
loop {
838
815
match try_update_from_dist_ (
839
- download ,
840
- update_hash,
816
+ opts . dl_cfg ,
817
+ opts . update_hash ,
841
818
& toolchain,
842
- profile,
819
+ match opts. exists {
820
+ false => Some ( opts. profile ) ,
821
+ true => None ,
822
+ } ,
843
823
prefix,
844
- force_update ,
845
- components,
846
- targets,
824
+ opts . force ,
825
+ opts . components ,
826
+ opts . targets ,
847
827
& mut fetched,
848
828
)
849
829
. await
@@ -857,11 +837,13 @@ async fn update_from_dist_(
857
837
let cause = e. downcast_ref :: < DistError > ( ) ;
858
838
match cause {
859
839
Some ( DistError :: ToolchainComponentsMissing ( components, manifest, ..) ) => {
860
- ( download. notify_handler ) ( Notification :: SkippingNightlyMissingComponent (
861
- & toolchain,
862
- current_manifest. as_ref ( ) . unwrap_or ( manifest) ,
863
- components,
864
- ) ) ;
840
+ ( opts. dl_cfg . notify_handler ) (
841
+ Notification :: SkippingNightlyMissingComponent (
842
+ & toolchain,
843
+ current_manifest. as_ref ( ) . unwrap_or ( manifest) ,
844
+ components,
845
+ ) ,
846
+ ) ;
865
847
866
848
if first_err. is_none ( ) {
867
849
first_err = Some ( e) ;
0 commit comments