Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetTmutilExclusion: ignore failures to add or remove exclusions caused by signal 9 #1438

Merged
merged 1 commit into from
Feb 14, 2025
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