@@ -18,6 +18,7 @@ use crate::{
1818 GetManyRequest , ObserveItem , ObserveRequest , PushRequest , Request , RequestType ,
1919 MAX_MESSAGE_SIZE ,
2020 } ,
21+ provider:: events:: { ClientResult , ProgressError } ,
2122 util:: sink:: { Sink , TokioMpscSenderSink } ,
2223} ;
2324
@@ -478,9 +479,7 @@ impl Remote {
478479 let content = content. into ( ) ;
479480 let ( tx, rx) = tokio:: sync:: mpsc:: channel ( 64 ) ;
480481 let tx2 = tx. clone ( ) ;
481- let sink = TokioMpscSenderSink ( tx)
482- . with_map ( GetProgressItem :: Progress )
483- . with_map_err ( io:: Error :: other) ;
482+ let sink = TokioMpscSenderSink ( tx) . with_map ( GetProgressItem :: Progress ) ;
484483 let this = self . clone ( ) ;
485484 let fut = async move {
486485 let res = this. fetch_sink ( conn, content, sink) . await . into ( ) ;
@@ -503,7 +502,7 @@ impl Remote {
503502 & self ,
504503 mut conn : impl GetConnection ,
505504 content : impl Into < HashAndFormat > ,
506- progress : impl Sink < u64 , Error = io :: Error > ,
505+ progress : impl Sink < u64 , Error = irpc :: channel :: SendError > ,
507506 ) -> GetResult < Stats > {
508507 let content = content. into ( ) ;
509508 let local = self
@@ -556,9 +555,7 @@ impl Remote {
556555 pub fn execute_push ( & self , conn : Connection , request : PushRequest ) -> PushProgress {
557556 let ( tx, rx) = tokio:: sync:: mpsc:: channel ( 64 ) ;
558557 let tx2 = tx. clone ( ) ;
559- let sink = TokioMpscSenderSink ( tx)
560- . with_map ( PushProgressItem :: Progress )
561- . with_map_err ( io:: Error :: other) ;
558+ let sink = TokioMpscSenderSink ( tx) . with_map ( PushProgressItem :: Progress ) ;
562559 let this = self . clone ( ) ;
563560 let fut = async move {
564561 let res = this. execute_push_sink ( conn, request, sink) . await . into ( ) ;
@@ -577,7 +574,7 @@ impl Remote {
577574 & self ,
578575 conn : Connection ,
579576 request : PushRequest ,
580- progress : impl Sink < u64 , Error = io :: Error > ,
577+ progress : impl Sink < u64 , Error = irpc :: channel :: SendError > ,
581578 ) -> anyhow:: Result < Stats > {
582579 let hash = request. hash ;
583580 debug ! ( %hash, "pushing" ) ;
@@ -632,9 +629,7 @@ impl Remote {
632629 pub fn execute_get_with_opts ( & self , conn : Connection , request : GetRequest ) -> GetProgress {
633630 let ( tx, rx) = tokio:: sync:: mpsc:: channel ( 64 ) ;
634631 let tx2 = tx. clone ( ) ;
635- let sink = TokioMpscSenderSink ( tx)
636- . with_map ( GetProgressItem :: Progress )
637- . with_map_err ( io:: Error :: other) ;
632+ let sink = TokioMpscSenderSink ( tx) . with_map ( GetProgressItem :: Progress ) ;
638633 let this = self . clone ( ) ;
639634 let fut = async move {
640635 let res = this. execute_get_sink ( & conn, request, sink) . await . into ( ) ;
@@ -658,7 +653,7 @@ impl Remote {
658653 & self ,
659654 conn : & Connection ,
660655 request : GetRequest ,
661- mut progress : impl Sink < u64 , Error = io :: Error > ,
656+ mut progress : impl Sink < u64 , Error = irpc :: channel :: SendError > ,
662657 ) -> GetResult < Stats > {
663658 let store = self . store ( ) ;
664659 let root = request. hash ;
@@ -721,9 +716,7 @@ impl Remote {
721716 pub fn execute_get_many ( & self , conn : Connection , request : GetManyRequest ) -> GetProgress {
722717 let ( tx, rx) = tokio:: sync:: mpsc:: channel ( 64 ) ;
723718 let tx2 = tx. clone ( ) ;
724- let sink = TokioMpscSenderSink ( tx)
725- . with_map ( GetProgressItem :: Progress )
726- . with_map_err ( io:: Error :: other) ;
719+ let sink = TokioMpscSenderSink ( tx) . with_map ( GetProgressItem :: Progress ) ;
727720 let this = self . clone ( ) ;
728721 let fut = async move {
729722 let res = this. execute_get_many_sink ( conn, request, sink) . await . into ( ) ;
@@ -747,7 +740,7 @@ impl Remote {
747740 & self ,
748741 conn : Connection ,
749742 request : GetManyRequest ,
750- mut progress : impl Sink < u64 , Error = io :: Error > ,
743+ mut progress : impl Sink < u64 , Error = irpc :: channel :: SendError > ,
751744 ) -> GetResult < Stats > {
752745 let store = self . store ( ) ;
753746 let hash_seq = request. hashes . iter ( ) . copied ( ) . collect :: < HashSeq > ( ) ;
@@ -884,7 +877,7 @@ async fn get_blob_ranges_impl(
884877 header : AtBlobHeader ,
885878 hash : Hash ,
886879 store : & Store ,
887- mut progress : impl Sink < u64 , Error = io :: Error > ,
880+ mut progress : impl Sink < u64 , Error = irpc :: channel :: SendError > ,
888881) -> GetResult < AtEndBlob > {
889882 let ( mut content, size) = header. next ( ) . await ?;
890883 let Some ( size) = NonZeroU64 :: new ( size) else {
@@ -1048,11 +1041,20 @@ struct StreamContext<S> {
10481041
10491042impl < S > WriteProgress for StreamContext < S >
10501043where
1051- S : Sink < u64 , Error = io :: Error > ,
1044+ S : Sink < u64 , Error = irpc :: channel :: SendError > ,
10521045{
1053- async fn notify_payload_write ( & mut self , _index : u64 , _offset : u64 , len : usize ) {
1046+ async fn notify_payload_write (
1047+ & mut self ,
1048+ _index : u64 ,
1049+ _offset : u64 ,
1050+ len : usize ,
1051+ ) -> ClientResult {
10541052 self . payload_bytes_sent += len as u64 ;
1055- self . sender . send ( self . payload_bytes_sent ) . await . ok ( ) ;
1053+ self . sender
1054+ . send ( self . payload_bytes_sent )
1055+ . await
1056+ . map_err ( |e| ProgressError :: Internal { source : e. into ( ) } ) ?;
1057+ Ok ( ( ) )
10561058 }
10571059
10581060 fn log_other_write ( & mut self , _len : usize ) { }
0 commit comments