Skip to content
Merged
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
43 changes: 33 additions & 10 deletions src/action/macos/set_tmutil_exclusion.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::os::unix::process::ExitStatusExt as _;
use std::path::{Path, PathBuf};

use tokio::process::Command;
Expand Down Expand Up @@ -67,17 +68,28 @@ impl Action for SetTmutilExclusion {

#[tracing::instrument(level = "debug", skip_all)]
async fn execute(&mut self) -> Result<(), ActionError> {
execute_command(
let tmutil_ret = execute_command(
Command::new("tmutil")
.process_group(0)
.arg("addexclusion")
.arg(&self.path)
.stdin(std::process::Stdio::null()),
)
.await
.map_err(Self::error)?;

Ok(())
.await;

match tmutil_ret {
Ok(_) => Ok(()),
Err(err) => {
if let crate::action::ActionErrorKind::CommandOutput { ref output, .. } = err {
if output.status.signal() == Some(9) {
tracing::debug!(%err, "tmutil failed because it was killed with signal 9; ignoring");
return Ok(());
}
}

Err(Self::error(err))?
},
}
}

fn revert_description(&self) -> Vec<ActionDescription> {
Expand All @@ -86,16 +98,27 @@ impl Action for SetTmutilExclusion {

#[tracing::instrument(level = "debug", skip_all)]
async fn revert(&mut self) -> Result<(), ActionError> {
execute_command(
let tmutil_ret = execute_command(
Command::new("tmutil")
.process_group(0)
.arg("removeexclusion")
.arg(&self.path)
.stdin(std::process::Stdio::null()),
)
.await
.map_err(Self::error)?;

Ok(())
.await;

match tmutil_ret {
Ok(_) => Ok(()),
Err(err) => {
if let crate::action::ActionErrorKind::CommandOutput { ref output, .. } = err {
if output.status.signal() == Some(9) {
tracing::debug!(%err, "tmutil failed because it was killed with signal 9; ignoring");
return Ok(());
}
}

Err(Self::error(err))?
},
}
}
}
Loading