@@ -20,7 +20,11 @@ pub struct Sysroot {
20
20
}
21
21
22
22
impl 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 > {
24
28
let unpack_into = "cache" ;
25
29
26
30
fs:: create_dir_all ( unpack_into) ?;
@@ -31,12 +35,12 @@ impl Sysroot {
31
35
triple : triple. to_owned ( ) ,
32
36
} ;
33
37
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 ?;
38
42
if backends. contains ( & CodegenBackend :: Cranelift ) {
39
- download. get_and_extract ( Component :: Cranelift ) ?;
43
+ download. get_and_extract ( Component :: Cranelift ) . await ?;
40
44
}
41
45
42
46
let sysroot = download. into_sysroot ( ) ?;
@@ -141,7 +145,7 @@ impl SysrootDownload {
141
145
} )
142
146
}
143
147
144
- fn get_and_extract ( & self , component : Component ) -> anyhow:: Result < ( ) > {
148
+ async fn get_and_extract ( & self , component : Component ) -> anyhow:: Result < ( ) > {
145
149
let archive_path = self . directory . join ( format ! (
146
150
"{}-{}-{}.tar.xz" ,
147
151
self . rust_sha, self . triple, component,
@@ -168,10 +172,11 @@ impl SysrootDownload {
168
172
] ;
169
173
for url in & urls {
170
174
log:: debug!( "requesting: {}" , url) ;
171
- let resp = reqwest:: blocking :: get ( url) ?;
175
+ let resp = reqwest:: get ( url) . await ?;
172
176
log:: debug!( "{}" , resp. status( ) ) ;
173
177
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 ( ) ) ) ;
175
180
match self . extract ( component, reader) {
176
181
Ok ( ( ) ) => return Ok ( ( ) ) ,
177
182
Err ( err) => {
0 commit comments