@@ -19,14 +19,10 @@ use iroh::{NodeAddr, PublicKey, RelayUrl};
19
19
use tokio:: io:: AsyncWriteExt ;
20
20
21
21
use crate :: {
22
- get:: {
23
- progress:: { BlobProgress , DownloadProgress } ,
24
- Stats ,
25
- } ,
26
- provider:: AddProgress ,
22
+ get:: Stats ,
27
23
rpc:: client:: blobs:: {
28
- self , BlobInfo , BlobStatus , CollectionInfo , DownloadMode , DownloadOptions ,
29
- IncompleteBlobInfo , WrapOption ,
24
+ self , AddProgressEvent , BlobInfo , BlobProgressEvent , BlobStatus , CollectionInfo ,
25
+ DownloadMode , DownloadOptions , DownloadProgressEvent , IncompleteBlobInfo , WrapOption ,
30
26
} ,
31
27
store:: { ConsistencyCheckProgress , ExportFormat , ExportMode , ReportLevel , ValidateProgress } ,
32
28
ticket:: BlobTicket ,
@@ -898,29 +894,29 @@ pub struct ProvideResponseEntry {
898
894
pub hash : Hash ,
899
895
}
900
896
901
- /// Combines the [`AddProgress `] outputs from a [`Stream`] into a single tuple.
897
+ /// Combines the [`AddProgressEvent `] outputs from a [`Stream`] into a single tuple.
902
898
pub async fn aggregate_add_response (
903
- mut stream : impl Stream < Item = Result < AddProgress > > + Unpin ,
899
+ mut stream : impl Stream < Item = Result < AddProgressEvent > > + Unpin ,
904
900
) -> Result < ( Hash , BlobFormat , Vec < ProvideResponseEntry > ) > {
905
901
let mut hash_and_format = None ;
906
902
let mut collections = BTreeMap :: < u64 , ( String , u64 , Option < Hash > ) > :: new ( ) ;
907
903
let mut mp = Some ( ProvideProgressState :: new ( ) ) ;
908
904
while let Some ( item) = stream. next ( ) . await {
909
905
match item? {
910
- AddProgress :: Found { name, id, size } => {
906
+ AddProgressEvent :: Found { name, id, size } => {
911
907
tracing:: trace!( "Found({id},{name},{size})" ) ;
912
908
if let Some ( mp) = mp. as_mut ( ) {
913
909
mp. found ( name. clone ( ) , id, size) ;
914
910
}
915
911
collections. insert ( id, ( name, size, None ) ) ;
916
912
}
917
- AddProgress :: Progress { id, offset } => {
913
+ AddProgressEvent :: Progress { id, offset } => {
918
914
tracing:: trace!( "Progress({id}, {offset})" ) ;
919
915
if let Some ( mp) = mp. as_mut ( ) {
920
916
mp. progress ( id, offset) ;
921
917
}
922
918
}
923
- AddProgress :: Done { hash, id } => {
919
+ AddProgressEvent :: Done { hash, id } => {
924
920
tracing:: trace!( "Done({id},{hash:?})" ) ;
925
921
if let Some ( mp) = mp. as_mut ( ) {
926
922
mp. done ( id, hash) ;
@@ -934,15 +930,15 @@ pub async fn aggregate_add_response(
934
930
}
935
931
}
936
932
}
937
- AddProgress :: AllDone { hash, format, .. } => {
933
+ AddProgressEvent :: AllDone { hash, format, .. } => {
938
934
tracing:: trace!( "AllDone({hash:?})" ) ;
939
935
if let Some ( mp) = mp. take ( ) {
940
936
mp. all_done ( ) ;
941
937
}
942
938
hash_and_format = Some ( HashAndFormat { hash, format } ) ;
943
939
break ;
944
940
}
945
- AddProgress :: Abort ( e) => {
941
+ AddProgressEvent :: Abort ( e) => {
946
942
if let Some ( mp) = mp. take ( ) {
947
943
mp. error ( ) ;
948
944
}
@@ -1035,7 +1031,7 @@ impl ProvideProgressState {
1035
1031
/// Displays the download progress for a given stream.
1036
1032
pub async fn show_download_progress (
1037
1033
hash : Hash ,
1038
- mut stream : impl Stream < Item = Result < DownloadProgress > > + Unpin ,
1034
+ mut stream : impl Stream < Item = Result < DownloadProgressEvent > > + Unpin ,
1039
1035
) -> Result < ( ) > {
1040
1036
eprintln ! ( "Fetching: {}" , hash) ;
1041
1037
let mp = MultiProgress :: new ( ) ;
@@ -1046,7 +1042,7 @@ pub async fn show_download_progress(
1046
1042
let mut seq = false ;
1047
1043
while let Some ( x) = stream. next ( ) . await {
1048
1044
match x? {
1049
- DownloadProgress :: InitialState ( state) => {
1045
+ DownloadProgressEvent :: InitialState ( state) => {
1050
1046
if state. connected {
1051
1047
op. set_message ( format ! ( "{} Requesting ...\n " , style( "[2/3]" ) . bold( ) . dim( ) ) ) ;
1052
1048
}
@@ -1066,21 +1062,21 @@ pub async fn show_download_progress(
1066
1062
ip. set_length ( size. value ( ) ) ;
1067
1063
ip. reset ( ) ;
1068
1064
match blob. progress {
1069
- BlobProgress :: Pending => { }
1070
- BlobProgress :: Progressing ( offset) => ip. set_position ( offset) ,
1071
- BlobProgress :: Done => ip. finish_and_clear ( ) ,
1065
+ BlobProgressEvent :: Pending => { }
1066
+ BlobProgressEvent :: Progressing ( offset) => ip. set_position ( offset) ,
1067
+ BlobProgressEvent :: Done => ip. finish_and_clear ( ) ,
1072
1068
}
1073
1069
if !seq {
1074
1070
op. finish_and_clear ( ) ;
1075
1071
}
1076
1072
}
1077
1073
}
1078
1074
}
1079
- DownloadProgress :: FoundLocal { .. } => { }
1080
- DownloadProgress :: Connected => {
1075
+ DownloadProgressEvent :: FoundLocal { .. } => { }
1076
+ DownloadProgressEvent :: Connected => {
1081
1077
op. set_message ( format ! ( "{} Requesting ...\n " , style( "[2/3]" ) . bold( ) . dim( ) ) ) ;
1082
1078
}
1083
- DownloadProgress :: FoundHashSeq { children, .. } => {
1079
+ DownloadProgressEvent :: FoundHashSeq { children, .. } => {
1084
1080
op. set_message ( format ! (
1085
1081
"{} Downloading {} blob(s)\n " ,
1086
1082
style( "[3/3]" ) . bold( ) . dim( ) ,
@@ -1090,7 +1086,7 @@ pub async fn show_download_progress(
1090
1086
op. reset ( ) ;
1091
1087
seq = true ;
1092
1088
}
1093
- DownloadProgress :: Found { size, child, .. } => {
1089
+ DownloadProgressEvent :: Found { size, child, .. } => {
1094
1090
if seq {
1095
1091
op. set_position ( child. into ( ) ) ;
1096
1092
} else {
@@ -1099,13 +1095,13 @@ pub async fn show_download_progress(
1099
1095
ip. set_length ( size) ;
1100
1096
ip. reset ( ) ;
1101
1097
}
1102
- DownloadProgress :: Progress { offset, .. } => {
1098
+ DownloadProgressEvent :: Progress { offset, .. } => {
1103
1099
ip. set_position ( offset) ;
1104
1100
}
1105
- DownloadProgress :: Done { .. } => {
1101
+ DownloadProgressEvent :: Done { .. } => {
1106
1102
ip. finish_and_clear ( ) ;
1107
1103
}
1108
- DownloadProgress :: AllDone ( Stats {
1104
+ DownloadProgressEvent :: AllDone ( Stats {
1109
1105
bytes_read,
1110
1106
elapsed,
1111
1107
..
@@ -1119,7 +1115,7 @@ pub async fn show_download_progress(
1119
1115
) ;
1120
1116
break ;
1121
1117
}
1122
- DownloadProgress :: Abort ( e) => {
1118
+ DownloadProgressEvent :: Abort ( e) => {
1123
1119
bail ! ( "download aborted: {}" , e) ;
1124
1120
}
1125
1121
}
0 commit comments