From b74bb50a15b3b94d6c7138a8ca40aedc92de5f69 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Sat, 6 Feb 2021 18:01:43 -0700 Subject: Clean up structure used for activation command error sending --- src/deploy.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/deploy.rs b/src/deploy.rs index aba41f2..62c97d0 100644 --- a/src/deploy.rs +++ b/src/deploy.rs @@ -299,16 +299,18 @@ pub async fn deploy_profile( tokio::spawn(async move { let o = ssh_activate.wait_with_output().await; - // Don't event unless somethis is bad - // TODO: maybe replace the structure with our own - match o { + let maybe_err = match o { + Err(x) => Some(DeployProfileError::SSHActivateError(x)), Ok(ref x) => match x.status.code() { - Some(0) => (), - _ => send_activate.send(o).unwrap(), + Some(0) => None, + a => Some(DeployProfileError::SSHActivateExitError(a)), }, - _ => send_activate.send(o).unwrap(), }; + if let Some(err) = maybe_err { + send_activate.send(err).unwrap(); + } + send_activated.send(()).unwrap(); }); @@ -321,11 +323,7 @@ pub async fn deploy_profile( }; }, x = recv_activate => { - debug!("Activate command exited with an error"); - match x.unwrap().map_err(DeployProfileError::SSHActivateError)?.status.code() { - Some(0) => unreachable!(), // We know it is an error, see a comment above - a => return Err(DeployProfileError::SSHActivateExitError(a)), - }; + return Err(x.unwrap()); }, } -- cgit v1.2.3