Skip to content

Commit a76908d

Browse files
committed
fixup: use wait_for_nix_store_dir() in CreateNixVolume
1 parent 0afa743 commit a76908d

2 files changed

Lines changed: 6 additions & 57 deletions

File tree

src/action/macos/create_determinate_nix_volume.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::{
2-
path::{Path, PathBuf},
3-
time::Duration,
4-
};
1+
use std::path::{Path, PathBuf};
52

63
use tokio::process::Command;
74
use tracing::{span, Span};
@@ -183,30 +180,9 @@ impl Action for CreateDeterminateNixVolume {
183180
.await
184181
.map_err(Self::error)?;
185182

186-
let mut retry_tokens: usize = 50;
187-
loop {
188-
let mut command = Command::new("/usr/sbin/diskutil");
189-
command.args(["info", "-plist"]);
190-
command.arg(&self.name);
191-
command.stderr(std::process::Stdio::null());
192-
command.stdout(std::process::Stdio::null());
193-
tracing::trace!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store volume existence");
194-
let output = command
195-
.output()
196-
.await
197-
.map_err(|e| ActionErrorKind::command(&command, e))
198-
.map_err(Self::error)?;
199-
if output.status.success() {
200-
break;
201-
} else if retry_tokens == 0 {
202-
return Err(Self::error(ActionErrorKind::command_output(
203-
&command, output,
204-
)));
205-
} else {
206-
retry_tokens = retry_tokens.saturating_sub(1);
207-
}
208-
tokio::time::sleep(Duration::from_millis(100)).await;
209-
}
183+
crate::action::macos::wait_for_nix_store_dir()
184+
.await
185+
.map_err(Self::error)?;
210186

211187
self.create_fstab_entry
212188
.try_execute()

src/action/macos/create_nix_volume.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ use crate::action::{
66
},
77
Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction,
88
};
9-
use std::{
10-
path::{Path, PathBuf},
11-
time::Duration,
12-
};
13-
use tokio::process::Command;
9+
use std::path::{Path, PathBuf};
1410
use tracing::{span, Span};
1511

1612
use super::{
@@ -179,30 +175,7 @@ impl Action for CreateNixVolume {
179175
.await
180176
.map_err(Self::error)?;
181177

182-
let mut retry_tokens: usize = 50;
183-
loop {
184-
let mut command = Command::new("/usr/sbin/diskutil");
185-
command.args(["info", "-plist"]);
186-
command.arg(&self.volume_label);
187-
command.stderr(std::process::Stdio::null());
188-
command.stdout(std::process::Stdio::null());
189-
tracing::trace!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store volume existence");
190-
let output = command
191-
.output()
192-
.await
193-
.map_err(|e| ActionErrorKind::command(&command, e))
194-
.map_err(Self::error)?;
195-
if output.status.success() {
196-
break;
197-
} else if retry_tokens == 0 {
198-
return Err(Self::error(ActionErrorKind::command_output(
199-
&command, output,
200-
)));
201-
} else {
202-
retry_tokens = retry_tokens.saturating_sub(1);
203-
}
204-
tokio::time::sleep(Duration::from_millis(100)).await;
205-
}
178+
super::wait_for_nix_store_dir().await.map_err(Self::error)?;
206179

207180
self.create_fstab_entry
208181
.try_execute()

0 commit comments

Comments
 (0)