@@ -349,34 +349,28 @@ impl OmaMultiProgressBar {
349349
350350 if let Some ( last_cause) = last {
351351 let reason = format ! ( "{first_cause}: {last_cause}" ) ;
352- if is_refresh {
353- self . error ( & fl ! (
354- "download-file-failed-with-reason" ,
355- filename = file_name,
356- reason = reason
357- ) ) ;
358- } else {
359- self . error ( & fl ! (
360- "download-package-failed-with-reason" ,
361- filename = file_name,
362- reason = reason
363- ) ) ;
364- }
352+ self . error_display ( & file_name, is_refresh, reason) ;
365353 } else if is_refresh {
354+ self . error_display ( & file_name, is_refresh, first_cause) ;
355+ }
356+
357+ debug ! ( "{:#?}" , errs) ;
358+ }
359+
360+ fn error_display ( & mut self , file_name : & String , is_refresh : bool , reason : String ) {
361+ if is_refresh {
366362 self . error ( & fl ! (
367363 "download-file-failed-with-reason" ,
368364 filename = file_name,
369- reason = first_cause
365+ reason = reason
370366 ) ) ;
371367 } else {
372368 self . error ( & fl ! (
373369 "download-package-failed-with-reason" ,
374370 filename = file_name,
375- reason = first_cause
371+ reason = reason
376372 ) ) ;
377373 }
378-
379- debug ! ( "{:#?}" , errs) ;
380374 }
381375}
382376
@@ -418,7 +412,7 @@ pub struct NoProgressBar {
418412impl RenderPackagesDownloadProgress for NoProgressBar {
419413 fn render_progress ( & mut self , rx : & flume:: Receiver < Event > , _download_only : bool ) {
420414 while let Ok ( event) = rx. recv ( ) {
421- if self . download_event ( event) {
415+ if self . download_event ( event, false ) {
422416 break ;
423417 }
424418 }
@@ -430,7 +424,7 @@ impl RenderRefreshProgress for NoProgressBar {
430424 while let Ok ( event) = rx. recv ( ) {
431425 match event {
432426 RefreshEvent :: DownloadEvent ( event) => {
433- self . download_event ( event) ;
427+ self . download_event ( event, true ) ;
434428 }
435429 RefreshEvent :: ClosingTopic ( topic) => {
436430 info ! ( "{}" , fl!( "scan-topic-is-removed" , name = topic) ) ;
@@ -453,7 +447,7 @@ impl RenderRefreshProgress for NoProgressBar {
453447}
454448
455449impl NoProgressBar {
456- fn download_event ( & mut self , event : Event ) -> bool {
450+ fn download_event ( & mut self , event : Event , is_refresh : bool ) -> bool {
457451 match event {
458452 Event :: ChecksumMismatch {
459453 index : _,
@@ -479,7 +473,7 @@ impl NoProgressBar {
479473 file_name,
480474 err,
481475 } => {
482- handle_no_pb_download_error ( file_name, err) ;
476+ handle_no_pb_download_error ( file_name, err, is_refresh ) ;
483477 info ! ( "{}" , fl!( "can-not-get-source-next-url" ) ) ;
484478 }
485479 Event :: DownloadDone { index : _, msg } => {
@@ -490,7 +484,7 @@ impl NoProgressBar {
490484 self . total_size . get_or_init ( || total_size) ;
491485 }
492486 Event :: Failed { file_name, error } => {
493- handle_no_pb_download_error ( file_name, error) ;
487+ handle_no_pb_download_error ( file_name, error, is_refresh ) ;
494488 }
495489 _ => { }
496490 } ;
@@ -517,7 +511,7 @@ impl NoProgressBar {
517511 }
518512}
519513
520- fn handle_no_pb_download_error ( file_name : String , error : SingleDownloadError ) {
514+ fn handle_no_pb_download_error ( file_name : String , error : SingleDownloadError , is_refresh : bool ) {
521515 if let SingleDownloadError :: ReqwestError { ref source } = error
522516 && source
523517 . status ( )
@@ -538,12 +532,33 @@ fn handle_no_pb_download_error(file_name: String, error: SingleDownloadError) {
538532
539533 if let Some ( last_cause) = last {
540534 let reason = format ! ( "{first_cause}: {last_cause}" ) ;
535+
536+ if is_refresh {
537+ error ! (
538+ "{}" ,
539+ fl!(
540+ "download-file-failed-with-reason" ,
541+ filename = file_name,
542+ reason = reason
543+ )
544+ ) ;
545+ } else {
546+ error ! (
547+ "{}" ,
548+ fl!(
549+ "download-package-failed-with-reason" ,
550+ filename = file_name,
551+ reason = reason
552+ )
553+ ) ;
554+ }
555+ } else if is_refresh {
541556 error ! (
542557 "{}" ,
543558 fl!(
544- "download-package -failed-with-reason" ,
559+ "download-file -failed-with-reason" ,
545560 filename = file_name,
546- reason = reason
561+ reason = first_cause
547562 )
548563 ) ;
549564 } else {
0 commit comments