@@ -22,7 +22,9 @@ pub enum RemoteProgressState {
2222 PackingDeltafiction ,
2323 ///
2424 Pushing ,
25- ///
25+ /// fetch progress
26+ Transfer ,
27+ /// remote progress done
2628 Done ,
2729}
2830
@@ -31,7 +33,7 @@ pub enum RemoteProgressState {
3133pub struct RemoteProgress {
3234 ///
3335 pub state : RemoteProgressState ,
34- ///
36+ /// percent 0..100
3537 pub progress : u8 ,
3638}
3739
@@ -52,23 +54,20 @@ impl RemoteProgress {
5254 progress : Arc < Mutex < Option < ProgressNotification > > > ,
5355 state : Option < ProgressNotification > ,
5456 ) -> Result < ( ) > {
55- let simple_progress: Option < RemoteProgress > =
56- state. as_ref ( ) . map ( |prog| prog. clone ( ) . into ( ) ) ;
57- log:: info!( "remote progress: {:?}" , simple_progress) ;
5857 let mut progress = progress. lock ( ) ?;
5958
6059 * progress = state;
6160
6261 Ok ( ( ) )
6362 }
6463
64+ /// spawn thread to listen to progress notifcations coming in from blocking remote git method (fetch/push)
6565 pub ( crate ) fn spawn_receiver_thread (
66+ notification_type : AsyncNotification ,
6667 sender : Sender < AsyncNotification > ,
6768 receiver : Receiver < ProgressNotification > ,
6869 progress : Arc < Mutex < Option < ProgressNotification > > > ,
6970 ) -> JoinHandle < ( ) > {
70- log:: info!( "push progress receiver spawned" ) ;
71-
7271 thread:: spawn ( move || loop {
7372 let incoming = receiver. recv ( ) ;
7473 match incoming {
@@ -79,11 +78,11 @@ impl RemoteProgress {
7978 )
8079 . expect ( "set prgoress failed" ) ;
8180 sender
82- . send ( AsyncNotification :: Push )
83- . expect ( "error sending push " ) ;
81+ . send ( notification_type )
82+ . expect ( "Notification error " ) ;
8483
8584 //NOTE: for better debugging
86- thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
85+ thread:: sleep ( Duration :: from_millis ( 1 ) ) ;
8786
8887 if let ProgressNotification :: Done = update {
8988 break ;
@@ -133,6 +132,15 @@ impl From<ProgressNotification> for RemoteProgress {
133132 current,
134133 total,
135134 ) ,
135+ ProgressNotification :: Transfer {
136+ objects,
137+ total_objects,
138+ ..
139+ } => RemoteProgress :: new (
140+ RemoteProgressState :: Transfer ,
141+ objects,
142+ total_objects,
143+ ) ,
136144 _ => RemoteProgress :: new ( RemoteProgressState :: Done , 1 , 1 ) ,
137145 }
138146 }
0 commit comments