@@ -93,12 +93,15 @@ fn download_file(url: &str, destination_file: &Path) -> Result<(), String> {
93
93
let progress_bar = new_spinner_progress_bar ( ) ;
94
94
progress_bar. set_message ( & format ! ( "{}Downloading {}..." , TRUCK , url) ) ;
95
95
96
- let client = reqwest:: blocking:: Client :: new ( ) ;
97
- let response = client. get ( url) . send ( ) . map_err ( |err| err. to_string ( ) ) ?;
96
+ let response = reqwest:: blocking:: Client :: new ( )
97
+ . get ( url)
98
+ . send ( )
99
+ . and_then ( |response| response. error_for_status ( ) )
100
+ . map_err ( |err| {
101
+ progress_bar. finish_and_clear ( ) ;
102
+ err. to_string ( )
103
+ } ) ?;
98
104
99
- let response = response
100
- . error_for_status ( )
101
- . map_err ( |err| format ! ( "Unable to download {}: {}" , url, err) ) ?;
102
105
let download_size = {
103
106
response
104
107
. headers ( )
@@ -139,9 +142,8 @@ fn download_file(url: &str, destination_file: &Path) -> Result<(), String> {
139
142
response,
140
143
} ;
141
144
142
- let mut file = File :: create ( & temp_destination_file)
143
- . map_err ( |err| format ! ( "Unable to create {:?}: {:?}" , temp_destination_file, err) ) ?;
144
- std:: io:: copy ( & mut source, & mut file)
145
+ File :: create ( & temp_destination_file)
146
+ . and_then ( |mut file| std:: io:: copy ( & mut source, & mut file) )
145
147
. map_err ( |err| format ! ( "Unable to write {:?}: {:?}" , temp_destination_file, err) ) ?;
146
148
147
149
source. progress_bar . finish_and_clear ( ) ;
@@ -1138,7 +1140,12 @@ pub fn main() {
1138
1140
} )
1139
1141
. and_then ( |_| {
1140
1142
if let Some ( snapshot_hash) = snapshot_hash {
1141
- download_snapshot ( & rpc_contact_info. rpc , & ledger_path, snapshot_hash)
1143
+ rpc_client. get_slot ( )
1144
+ . map_err ( |err| format ! ( "Failed to get RPC node slot: {}" , err) )
1145
+ . and_then ( |slot| {
1146
+ info ! ( "RPC node root slot: {}" , slot) ;
1147
+ download_snapshot ( & rpc_contact_info. rpc , & ledger_path, snapshot_hash)
1148
+ } )
1142
1149
} else {
1143
1150
Ok ( ( ) )
1144
1151
}
0 commit comments