@@ -7,11 +7,12 @@ use indicatif::{
77 HumanBytes , HumanDuration , MultiProgress , ProgressBar , ProgressDrawTarget , ProgressStyle ,
88} ;
99use iroh_bytes:: {
10+ get:: fsm:: DecodeError ,
1011 provider:: {
1112 self , handle_connection, DownloadProgress , EventSender , RequestAuthorizationHandler ,
1213 } ,
1314 store:: { ExportMode , ImportMode , ImportProgress } ,
14- BlobFormat , Hash , HashAndFormat , TempTag , get :: fsm :: DecodeError ,
15+ BlobFormat , Hash , HashAndFormat , TempTag ,
1516} ;
1617use iroh_bytes_util:: get_hash_seq_and_sizes;
1718use iroh_net:: { key:: SecretKey , MagicEndpoint } ;
@@ -585,24 +586,26 @@ pub async fn show_download_progress(
585586
586587fn show_get_error ( e : anyhow:: Error ) -> anyhow:: Error {
587588 if let Some ( err) = e. downcast_ref :: < DecodeError > ( ) {
588- let error_text = match err {
589+ match err {
589590 DecodeError :: NotFound => {
590- "provide side no longer has a file" . to_string ( )
591- }
592- DecodeError :: LeafNotFound ( _) | DecodeError :: ParentNotFound ( _) => {
593- "provide side no longer has part of a file" . to_string ( )
591+ eprintln ! ( "{}" , style( "provide side no longer has a file" ) . yellow( ) )
594592 }
593+ DecodeError :: LeafNotFound ( _) | DecodeError :: ParentNotFound ( _) => eprintln ! (
594+ "{}" ,
595+ style( "provide side no longer has part of a file" ) . yellow( )
596+ ) ,
597+ DecodeError :: Io ( err) => eprintln ! (
598+ "{}" ,
599+ style( format!( "generic network error: {}" , err) ) . yellow( )
600+ ) ,
601+ DecodeError :: Read ( err) => eprintln ! (
602+ "{}" ,
603+ style( format!( "error reading data from quinn: {}" , err) ) . yellow( )
604+ ) ,
595605 DecodeError :: LeafHashMismatch ( _) | DecodeError :: ParentHashMismatch ( _) => {
596- "provide side sent wrong data" . to_string ( )
597- }
598- DecodeError :: Io ( err) => {
599- format ! ( "generic network error: {}" , err)
600- }
601- DecodeError :: Read ( err) => {
602- format ! ( "error reading data from quinn: {}" , err)
606+ eprintln ! ( "{}" , style( "provide side sent wrong data" ) . red( ) )
603607 }
604608 } ;
605- eprintln ! ( "error: {}" , error_text) ;
606609 }
607610 e
608611}
@@ -640,8 +643,9 @@ async fn get(args: GetArgs) -> anyhow::Result<()> {
640643 let ( send, recv) = flume:: bounded ( 32 ) ;
641644 let progress = iroh_bytes:: util:: progress:: FlumeProgressSender :: new ( send) ;
642645 let ( _hash_seq, sizes) =
643- get_hash_seq_and_sizes ( & connection, & hash_and_format. hash , 1024 * 1024 * 32 ) . await
644- . map_err ( show_get_error) ?;
646+ get_hash_seq_and_sizes ( & connection, & hash_and_format. hash , 1024 * 1024 * 32 )
647+ . await
648+ . map_err ( show_get_error) ?;
645649 let total_size = sizes. iter ( ) . sum :: < u64 > ( ) ;
646650 let total_files = sizes. len ( ) . saturating_sub ( 1 ) ;
647651 let payload_size = sizes. iter ( ) . skip ( 1 ) . sum :: < u64 > ( ) ;
@@ -653,11 +657,16 @@ async fn get(args: GetArgs) -> anyhow::Result<()> {
653657 ) ;
654658 // print the details of the collection only in verbose mode
655659 if args. common . verbose > 0 {
656- eprintln ! ( "getting {} blobs in total, {}" , sizes. len( ) , HumanBytes ( total_size) ) ;
660+ eprintln ! (
661+ "getting {} blobs in total, {}" ,
662+ sizes. len( ) ,
663+ HumanBytes ( total_size)
664+ ) ;
657665 }
658666 let _task = tokio:: spawn ( show_download_progress ( recv. into_stream ( ) , total_size) ) ;
659- let _stats = get:: get ( & db, connection, & hash_and_format, progress) . await
660- . map_err ( show_get_error) ?;
667+ let _stats = get:: get ( & db, connection, & hash_and_format, progress)
668+ . await
669+ . map_err ( show_get_error) ?;
661670 let collection = Collection :: load ( & db, & hash_and_format. hash ) . await ?;
662671 if args. common . verbose > 0 {
663672 for ( name, hash) in collection. iter ( ) {
0 commit comments