diff --git a/asyncgit/src/fetch.rs b/asyncgit/src/fetch.rs index 2b80a623..448ffc7d 100644 --- a/asyncgit/src/fetch.rs +++ b/asyncgit/src/fetch.rs @@ -85,6 +85,7 @@ impl AsyncFetch { let (progress_sender, receiver) = unbounded(); let handle = RemoteProgress::spawn_receiver_thread( + AsyncNotification::Fetch, sender.clone(), receiver, arc_progress, diff --git a/asyncgit/src/push.rs b/asyncgit/src/push.rs index 7c032a3e..bd027d79 100644 --- a/asyncgit/src/push.rs +++ b/asyncgit/src/push.rs @@ -87,6 +87,7 @@ impl AsyncPush { let (progress_sender, receiver) = unbounded(); let handle = RemoteProgress::spawn_receiver_thread( + AsyncNotification::Push, sender.clone(), receiver, arc_progress, diff --git a/asyncgit/src/remote_progress.rs b/asyncgit/src/remote_progress.rs index ae293947..1d1cd27d 100644 --- a/asyncgit/src/remote_progress.rs +++ b/asyncgit/src/remote_progress.rs @@ -22,7 +22,9 @@ pub enum RemoteProgressState { PackingDeltafiction, /// Pushing, - /// + /// fetch progress + Transfer, + /// remote progress done Done, } @@ -31,7 +33,7 @@ pub enum RemoteProgressState { pub struct RemoteProgress { /// pub state: RemoteProgressState, - /// + /// percent 0..100 pub progress: u8, } @@ -52,9 +54,6 @@ impl RemoteProgress { progress: Arc>>, state: Option, ) -> Result<()> { - let simple_progress: Option = - state.as_ref().map(|prog| prog.clone().into()); - log::info!("remote progress: {:?}", simple_progress); let mut progress = progress.lock()?; *progress = state; @@ -62,13 +61,13 @@ impl RemoteProgress { Ok(()) } + /// spawn thread to listen to progress notifcations coming in from blocking remote git method (fetch/push) pub(crate) fn spawn_receiver_thread( + notification_type: AsyncNotification, sender: Sender, receiver: Receiver, progress: Arc>>, ) -> JoinHandle<()> { - log::info!("push progress receiver spawned"); - thread::spawn(move || loop { let incoming = receiver.recv(); match incoming { @@ -79,11 +78,11 @@ impl RemoteProgress { ) .expect("set prgoress failed"); sender - .send(AsyncNotification::Push) - .expect("error sending push"); + .send(notification_type) + .expect("Notification error"); //NOTE: for better debugging - thread::sleep(Duration::from_millis(100)); + thread::sleep(Duration::from_millis(1)); if let ProgressNotification::Done = update { break; @@ -133,6 +132,15 @@ impl From for RemoteProgress { current, total, ), + ProgressNotification::Transfer { + objects, + total_objects, + .. + } => RemoteProgress::new( + RemoteProgressState::Transfer, + objects, + total_objects, + ), _ => RemoteProgress::new(RemoteProgressState::Done, 1, 1), } } diff --git a/src/components/push.rs b/src/components/push.rs index 822840b1..f1068e17 100644 --- a/src/components/push.rs +++ b/src/components/push.rs @@ -169,6 +169,9 @@ impl PushComponent { RemoteProgressState::Pushing => { strings::PUSH_POPUP_STATES_PUSHING } + RemoteProgressState::Transfer => { + strings::PUSH_POPUP_STATES_TRANSFER + } RemoteProgressState::Done => { strings::PUSH_POPUP_STATES_DONE } diff --git a/src/strings.rs b/src/strings.rs index f9db6bf7..3f3c8808 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -11,6 +11,7 @@ pub static PUSH_POPUP_PROGRESS_NONE: &str = "preparing..."; pub static PUSH_POPUP_STATES_ADDING: &str = "adding objects (1/3)"; pub static PUSH_POPUP_STATES_DELTAS: &str = "deltas (2/3)"; pub static PUSH_POPUP_STATES_PUSHING: &str = "pushing (3/3)"; +pub static PUSH_POPUP_STATES_TRANSFER: &str = "transfer"; pub static PUSH_POPUP_STATES_DONE: &str = "done"; pub static SELECT_BRANCH_POPUP_MSG: &str = "Switch Branch";