@@ -49,44 +49,7 @@ async fn get_decompressor_error(
4949 }
5050}
5151
52- /// Handles retry logic for download errors.
53- ///
54- /// Returns `Some(Duration)` with the delay to wait before retrying, or `None` if
55- /// the error is non-retryable or max retries have been exceeded.
56- fn handle_retry_error (
57- error : & DownloadError ,
58- retry_count : & mut usize ,
59- max_retries : usize ,
60- default_retry_delay_secs : u64 ,
61- ) -> Option < Duration > {
62- if !error. is_retryable ( ) {
63- eprintln ! (
64- "\n Download failed with non-retryable error: {}" ,
65- error. format_error( )
66- ) ;
67- return None ;
68- }
69-
70- if * retry_count >= max_retries {
71- eprintln ! ( "\n Max retries ({}) reached, giving up" , max_retries) ;
72- eprintln ! ( "Last error: {}" , error. format_error( ) ) ;
73- return None ;
74- }
75-
76- let retry_delay = error
77- . suggested_retry_delay ( )
78- . unwrap_or_else ( || Duration :: from_secs ( default_retry_delay_secs) ) ;
79-
80- eprintln ! ( "\n Download failed: {}" , error. format_error( ) ) ;
81- eprintln ! (
82- "Retrying in {} seconds... (attempt {}/{})" ,
83- retry_delay. as_secs( ) ,
84- * retry_count + 1 ,
85- max_retries
86- ) ;
87- * retry_count += 1 ;
88- Some ( retry_delay)
89- }
52+ use crate :: fls:: download_error:: handle_download_retry;
9053
9154/// Execute a sequence of write commands on the block writer
9255async fn execute_write_commands (
@@ -407,7 +370,7 @@ pub async fn flash_from_url(
407370 match start_download ( url, & client, resume_from, & options. headers , debug) . await {
408371 Ok ( r) => r,
409372 Err ( e) => {
410- match handle_retry_error (
373+ match handle_download_retry (
411374 & e,
412375 & mut retry_count,
413376 options. max_retries ,
@@ -551,7 +514,7 @@ pub async fn flash_from_url(
551514
552515 if let Some ( e) = connection_error {
553516 eprintln ! ( "\n Connection interrupted: {}" , e. format_error( ) ) ;
554- match handle_retry_error (
517+ match handle_download_retry (
555518 & e,
556519 & mut retry_count,
557520 options. max_retries ,
0 commit comments