Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/action/base/create_or_insert_into_file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use nix::unistd::{chown, Group, User};

use crate::action::{
Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction,
use crate::{
action::{Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction},
util::OnMissing,
};
use rand::Rng;
use std::{
Expand All @@ -10,7 +11,7 @@ use std::{
path::{Path, PathBuf},
};
use tokio::{
fs::{remove_file, File, OpenOptions},
fs::{File, OpenOptions},
io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt},
};
use tracing::{span, Span};
Expand Down Expand Up @@ -367,7 +368,7 @@ impl Action for CreateOrInsertIntoFile {
}

if file_contents.is_empty() {
remove_file(&path)
crate::util::remove_file(&path, OnMissing::Ignore)
.await
.map_err(|e| ActionErrorKind::Remove(path.to_owned(), e))
.map_err(Self::error)?;
Expand Down
12 changes: 5 additions & 7 deletions src/action/base/create_or_merge_nix_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ use std::{

use nix_config_parser::NixConfig;
use rand::Rng;
use tokio::{
fs::{remove_file, OpenOptions},
io::AsyncWriteExt,
};
use tokio::{fs::OpenOptions, io::AsyncWriteExt};
use tracing::{span, Span};

use crate::action::{
Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction,
use crate::{
action::{Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction},
util::OnMissing,
};

pub(crate) const TRUSTED_USERS_CONF_NAME: &str = "trusted-users";
Expand Down Expand Up @@ -457,7 +455,7 @@ impl Action for CreateOrMergeNixConfig {

#[tracing::instrument(level = "debug", skip_all)]
async fn revert(&mut self) -> Result<(), ActionError> {
remove_file(&self.path)
crate::util::remove_file(&self.path, OnMissing::Ignore)
.await
.map_err(|e| Self::error(ActionErrorKind::Remove(self.path.to_owned(), e)))?;

Expand Down
9 changes: 3 additions & 6 deletions src/action/macos/create_determinate_volume_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ use std::{
path::{Path, PathBuf},
process::Stdio,
};
use tokio::{
fs::{remove_file, OpenOptions},
io::AsyncWriteExt,
process::Command,
};
use tokio::{fs::OpenOptions, io::AsyncWriteExt, process::Command};

use crate::{
action::{Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction},
execute_command,
util::OnMissing,
};

use super::DARWIN_LAUNCHD_DOMAIN;
Expand Down Expand Up @@ -178,7 +175,7 @@ impl Action for CreateDeterminateVolumeService {

#[tracing::instrument(level = "debug", skip_all)]
async fn revert(&mut self) -> Result<(), ActionError> {
remove_file(&self.path)
crate::util::remove_file(&self.path, OnMissing::Ignore)
.await
.map_err(|e| Self::error(ActionErrorKind::Remove(self.path.to_owned(), e)))?;

Expand Down
9 changes: 3 additions & 6 deletions src/action/macos/create_nix_hook_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ use serde::{Deserialize, Serialize};
use tracing::{span, Span};

use std::{path::PathBuf, process::Stdio};
use tokio::{
fs::{remove_file, OpenOptions},
io::AsyncWriteExt,
process::Command,
};
use tokio::{fs::OpenOptions, io::AsyncWriteExt, process::Command};

use crate::{
action::{Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction},
execute_command,
util::OnMissing,
};

use super::DARWIN_LAUNCHD_DOMAIN;
Expand Down Expand Up @@ -159,7 +156,7 @@ impl Action for CreateNixHookService {

#[tracing::instrument(level = "debug", skip_all)]
async fn revert(&mut self) -> Result<(), ActionError> {
remove_file(&self.path)
crate::util::remove_file(&self.path, OnMissing::Ignore)
.await
.map_err(|e| Self::error(ActionErrorKind::Remove(self.path.to_owned(), e)))?;

Expand Down
9 changes: 3 additions & 6 deletions src/action/macos/create_volume_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ use std::{
path::{Path, PathBuf},
process::Stdio,
};
use tokio::{
fs::{remove_file, OpenOptions},
io::AsyncWriteExt,
process::Command,
};
use tokio::{fs::OpenOptions, io::AsyncWriteExt, process::Command};

use crate::{
action::{
macos::DARWIN_LAUNCHD_DOMAIN, Action, ActionDescription, ActionError, ActionErrorKind,
ActionTag, StatefulAction,
},
execute_command,
util::OnMissing,
};

use super::get_disk_info_for_label;
Expand Down Expand Up @@ -248,7 +245,7 @@ impl Action for CreateVolumeService {

#[tracing::instrument(level = "debug", skip_all)]
async fn revert(&mut self) -> Result<(), ActionError> {
remove_file(&self.path)
crate::util::remove_file(&self.path, OnMissing::Ignore)
.await
.map_err(|e| Self::error(ActionErrorKind::Remove(self.path.to_owned(), e)))?;

Expand Down
Loading