diff --git a/src/action/common/configure_determinate_nixd_init_service/mod.rs b/src/action/common/configure_determinate_nixd_init_service/mod.rs index d8475807d..a27ce320d 100644 --- a/src/action/common/configure_determinate_nixd_init_service/mod.rs +++ b/src/action/common/configure_determinate_nixd_init_service/mod.rs @@ -162,20 +162,6 @@ impl Action for ConfigureDeterminateNixdInitService { async fn revert(&mut self) -> Result<(), ActionError> { self.configure_init_service.try_revert().await?; - let file_to_remove = match self.init { - InitSystem::Launchd => Some(DARWIN_NIXD_DAEMON_DEST), - InitSystem::Systemd => Some(LINUX_NIXD_DAEMON_DEST), - InitSystem::None => None, - }; - - if let Some(file_to_remove) = file_to_remove { - tracing::trace!(path = %file_to_remove, "Removing"); - tokio::fs::remove_file(file_to_remove) - .await - .map_err(|e| ActionErrorKind::Remove(file_to_remove.into(), e)) - .map_err(Self::error)?; - } - Ok(()) } } diff --git a/src/action/common/configure_init_service.rs b/src/action/common/configure_init_service.rs index 2714b0d75..cd9871d74 100644 --- a/src/action/common/configure_init_service.rs +++ b/src/action/common/configure_init_service.rs @@ -610,18 +610,6 @@ impl Action for ConfigureInitService { errors.push(err); } - for socket in self.socket_files.iter() { - if socket.dest.exists() { - tracing::trace!(path = %socket.dest.display(), "Removing"); - if let Err(err) = tokio::fs::remove_file(&socket.dest) - .await - .map_err(|e| ActionErrorKind::Remove(socket.dest.to_path_buf(), e)) - { - errors.push(err); - } - } - } - if Path::new(TMPFILES_DEST).exists() { if let Err(err) = tokio::fs::remove_file(TMPFILES_DEST) .await @@ -647,6 +635,30 @@ impl Action for ConfigureInitService { }, }; + if let Some(dest) = &self.service_dest { + if dest.exists() { + tracing::trace!(path = %dest.display(), "Removing"); + if let Err(err) = tokio::fs::remove_file(dest) + .await + .map_err(|e| ActionErrorKind::Remove(PathBuf::from(dest), e)) + { + errors.push(err); + } + } + } + + for socket in self.socket_files.iter() { + if socket.dest.exists() { + tracing::trace!(path = %socket.dest.display(), "Removing"); + if let Err(err) = tokio::fs::remove_file(&socket.dest) + .await + .map_err(|e| ActionErrorKind::Remove(socket.dest.to_path_buf(), e)) + { + errors.push(err); + } + } + } + if errors.is_empty() { Ok(()) } else if errors.len() == 1 {