@@ -20,7 +20,11 @@ pub struct Sysroot {
2020}
2121
2222impl Sysroot {
23- pub fn install ( sha : String , triple : & str , backends : & [ CodegenBackend ] ) -> anyhow:: Result < Self > {
23+ pub async fn install (
24+ sha : String ,
25+ triple : & str ,
26+ backends : & [ CodegenBackend ] ,
27+ ) -> anyhow:: Result < Self > {
2428 let unpack_into = "cache" ;
2529
2630 fs:: create_dir_all ( unpack_into) ?;
@@ -31,12 +35,12 @@ impl Sysroot {
3135 triple : triple. to_owned ( ) ,
3236 } ;
3337
34- download. get_and_extract ( Component :: Rustc ) ?;
35- download. get_and_extract ( Component :: Std ) ?;
36- download. get_and_extract ( Component :: Cargo ) ?;
37- download. get_and_extract ( Component :: RustSrc ) ?;
38+ download. get_and_extract ( Component :: Rustc ) . await ?;
39+ download. get_and_extract ( Component :: Std ) . await ?;
40+ download. get_and_extract ( Component :: Cargo ) . await ?;
41+ download. get_and_extract ( Component :: RustSrc ) . await ?;
3842 if backends. contains ( & CodegenBackend :: Cranelift ) {
39- download. get_and_extract ( Component :: Cranelift ) ?;
43+ download. get_and_extract ( Component :: Cranelift ) . await ?;
4044 }
4145
4246 let sysroot = download. into_sysroot ( ) ?;
@@ -141,7 +145,7 @@ impl SysrootDownload {
141145 } )
142146 }
143147
144- fn get_and_extract ( & self , component : Component ) -> anyhow:: Result < ( ) > {
148+ async fn get_and_extract ( & self , component : Component ) -> anyhow:: Result < ( ) > {
145149 let archive_path = self . directory . join ( format ! (
146150 "{}-{}-{}.tar.xz" ,
147151 self . rust_sha, self . triple, component,
@@ -168,10 +172,11 @@ impl SysrootDownload {
168172 ] ;
169173 for url in & urls {
170174 log:: debug!( "requesting: {}" , url) ;
171- let resp = reqwest:: blocking :: get ( url) ?;
175+ let resp = reqwest:: get ( url) . await ?;
172176 log:: debug!( "{}" , resp. status( ) ) ;
173177 if resp. status ( ) . is_success ( ) {
174- let reader = XzDecoder :: new ( BufReader :: new ( resp) ) ;
178+ let bytes: Vec < u8 > = resp. bytes ( ) . await ?. into ( ) ;
179+ let reader = XzDecoder :: new ( BufReader :: new ( bytes. as_slice ( ) ) ) ;
175180 match self . extract ( component, reader) {
176181 Ok ( ( ) ) => return Ok ( ( ) ) ,
177182 Err ( err) => {
0 commit comments