diff --git a/src/action/macos/create_determinate_nix_volume.rs b/src/action/macos/create_determinate_nix_volume.rs index 987ea69cd..bedc356ae 100644 --- a/src/action/macos/create_determinate_nix_volume.rs +++ b/src/action/macos/create_determinate_nix_volume.rs @@ -1,7 +1,4 @@ -use std::{ - path::{Path, PathBuf}, - time::Duration, -}; +use std::path::{Path, PathBuf}; use tokio::process::Command; use tracing::{span, Span}; @@ -183,30 +180,9 @@ impl Action for CreateDeterminateNixVolume { .await .map_err(Self::error)?; - let mut retry_tokens: usize = 50; - loop { - let mut command = Command::new("/usr/sbin/diskutil"); - command.args(["info", "-plist"]); - command.arg(&self.name); - command.stderr(std::process::Stdio::null()); - command.stdout(std::process::Stdio::null()); - tracing::trace!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store volume existence"); - let output = command - .output() - .await - .map_err(|e| ActionErrorKind::command(&command, e)) - .map_err(Self::error)?; - if output.status.success() { - break; - } else if retry_tokens == 0 { - return Err(Self::error(ActionErrorKind::command_output( - &command, output, - ))); - } else { - retry_tokens = retry_tokens.saturating_sub(1); - } - tokio::time::sleep(Duration::from_millis(100)).await; - } + crate::action::macos::wait_for_nix_store_dir() + .await + .map_err(Self::error)?; self.create_fstab_entry .try_execute() diff --git a/src/action/macos/create_nix_volume.rs b/src/action/macos/create_nix_volume.rs index 14abf1788..52d4ea2f0 100644 --- a/src/action/macos/create_nix_volume.rs +++ b/src/action/macos/create_nix_volume.rs @@ -6,11 +6,7 @@ use crate::action::{ }, Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction, }; -use std::{ - path::{Path, PathBuf}, - time::Duration, -}; -use tokio::process::Command; +use std::path::{Path, PathBuf}; use tracing::{span, Span}; use super::{ @@ -179,30 +175,7 @@ impl Action for CreateNixVolume { .await .map_err(Self::error)?; - let mut retry_tokens: usize = 50; - loop { - let mut command = Command::new("/usr/sbin/diskutil"); - command.args(["info", "-plist"]); - command.arg(&self.volume_label); - command.stderr(std::process::Stdio::null()); - command.stdout(std::process::Stdio::null()); - tracing::trace!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store volume existence"); - let output = command - .output() - .await - .map_err(|e| ActionErrorKind::command(&command, e)) - .map_err(Self::error)?; - if output.status.success() { - break; - } else if retry_tokens == 0 { - return Err(Self::error(ActionErrorKind::command_output( - &command, output, - ))); - } else { - retry_tokens = retry_tokens.saturating_sub(1); - } - tokio::time::sleep(Duration::from_millis(100)).await; - } + super::wait_for_nix_store_dir().await.map_err(Self::error)?; self.create_fstab_entry .try_execute()