From a317b0bcac88725771476d8430caec957ae5e91d Mon Sep 17 00:00:00 2001 From: Christian Höppner Date: Thu, 19 Nov 2020 11:18:28 +0000 Subject: Check auto-rollback flag before deactivating --- src/activate.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/activate.rs') diff --git a/src/activate.rs b/src/activate.rs index 215c086..cc80876 100644 --- a/src/activate.rs +++ b/src/activate.rs @@ -288,7 +288,9 @@ pub async fn activate( match nix_env_set_exit_status.code() { Some(0) => (), a => { - deactivate(&profile_path).await?; + if auto_rollback { + deactivate(&profile_path).await?; + } return Err(ActivateError::SetProfileExitError(a)); } }; @@ -302,7 +304,9 @@ pub async fn activate( { Ok(x) => x, Err(e) => { - deactivate(&profile_path).await?; + if auto_rollback { + deactivate(&profile_path).await?; + } return Err(e); } }; @@ -310,7 +314,9 @@ pub async fn activate( match activate_status.code() { Some(0) => (), a => { - deactivate(&profile_path).await?; + if auto_rollback { + deactivate(&profile_path).await?; + } return Err(ActivateError::RunActivateExitError(a)); } }; @@ -324,7 +330,9 @@ pub async fn activate( { Ok(()) => {} Err(err) => { - deactivate(&profile_path).await?; + if auto_rollback { + deactivate(&profile_path).await?; + } return Err(ActivateError::ActivationConfirmationError(err)); } }; -- cgit v1.2.3