11use anyhow:: Context ;
2- use std:: path:: PathBuf ;
3- use tokio:: task:: JoinSet ;
42use indicatif:: { MultiProgress , ProgressBar , ProgressStyle } ;
53use std:: io:: IsTerminal ;
4+ use std:: path:: { Path , PathBuf } ;
5+ use tokio:: task:: JoinSet ;
66
77use crate :: files:: archive_filepath_from_opts;
88
@@ -159,7 +159,8 @@ impl Bootstrap {
159159
160160 if download_node_archives {
161161 tracing:: info!( "downloading node archives for chain {}" , chain_id) ;
162- Bootstrap :: download_node_archives_static ( & chain_id, & home, force) . await
162+ Bootstrap :: download_node_archives_static ( & chain_id, & home, force)
163+ . await
163164 . context ( "failed to download node archives" ) ?;
164165 }
165166
@@ -169,7 +170,7 @@ impl Bootstrap {
169170 /// Download all NodeArchives for a given chain in parallel with progress bars.
170171 pub async fn download_node_archives_static (
171172 chain_id : & str ,
172- home : & PathBuf ,
173+ home : & Path ,
173174 force : bool ,
174175 ) -> anyhow:: Result < ( ) > {
175176 let node_archive_series = crate :: history:: NodeArchiveSeries :: from_chain_id ( chain_id)
@@ -199,7 +200,7 @@ impl Bootstrap {
199200 let mut join_set = JoinSet :: new ( ) ;
200201
201202 for ( index, archive) in archives. into_iter ( ) . enumerate ( ) {
202- let home_dir = home. clone ( ) ;
203+ let home_dir = home. to_path_buf ( ) ;
203204 let chain_id_clone = chain_id. to_string ( ) ;
204205 let multi_progress_clone = multi_progress. clone ( ) ;
205206
@@ -242,11 +243,7 @@ impl Bootstrap {
242243 for error in & errors {
243244 tracing:: error!( " {}" , error) ;
244245 }
245- anyhow:: bail!(
246- "{} of {} downloads failed" ,
247- errors. len( ) ,
248- num_archives
249- ) ;
246+ anyhow:: bail!( "{} of {} downloads failed" , errors. len( ) , num_archives) ;
250247 }
251248
252249 tracing:: info!(
@@ -260,7 +257,7 @@ impl Bootstrap {
260257
261258 async fn download_single_node_archive (
262259 archive : crate :: history:: NodeArchive ,
263- home : & PathBuf ,
260+ home : & Path ,
264261 chain_id : & str ,
265262 force : bool ,
266263 _index : usize ,
@@ -330,18 +327,19 @@ impl Bootstrap {
330327 let existing_hash = Self :: get_sha256sum ( dest_file) ?;
331328 if existing_hash == checksum_sha256 {
332329 if let Some ( pb) = progress_bar {
333- pb. set_message ( format ! ( "{}: Already exists with correct checksum" , basename) ) ;
330+ pb. set_message ( format ! (
331+ "{}: Already exists with correct checksum" ,
332+ basename
333+ ) ) ;
334334 }
335335 return Ok ( ( ) ) ;
336- } else {
337- if let Some ( pb) = progress_bar {
338- pb. set_message ( format ! ( "{}: Re-downloading (checksum mismatch)" , basename) ) ;
339- }
336+ } else if let Some ( pb) = progress_bar {
337+ pb. set_message ( format ! ( "{}: Re-downloading (checksum mismatch)" , basename) ) ;
340338 }
341339 }
342340
343341 let client = Client :: new ( ) ;
344-
342+
345343 let total_size = match client. head ( download_url. clone ( ) ) . send ( ) . await {
346344 Ok ( response) => response
347345 . headers ( )
@@ -366,13 +364,13 @@ impl Bootstrap {
366364 }
367365
368366 let response = client. get ( download_url. clone ( ) ) . send ( ) . await ?;
369-
367+
370368 if !response. status ( ) . is_success ( ) {
371369 anyhow:: bail!( "Failed to download: HTTP {}" , response. status( ) ) ;
372370 }
373371
374- let mut file = std :: fs :: File :: create ( dest_file )
375- . context ( "failed to create destination file" ) ?;
372+ let mut file =
373+ std :: fs :: File :: create ( dest_file ) . context ( "failed to create destination file" ) ?;
376374
377375 let mut stream = response. bytes_stream ( ) ;
378376 let mut downloaded = 0u64 ;
0 commit comments