Skip to content

Commit

Permalink
configure_init_service: only try to copy the service src if one is pr…
Browse files Browse the repository at this point in the history
…ovided, since it may not be (#1068)
  • Loading branch information
grahamc authored Jul 31, 2024
1 parent b322db2 commit 75c3e93
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/action/common/configure_init_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ impl Action for ConfigureInitService {

match init {
InitSystem::Launchd => {
let service_src = service_src
.as_ref()
.expect("service_src should be defined for launchd");

let service_dest = service_dest
.as_ref()
.expect("service_dest should be set for Launchd");
Expand All @@ -218,15 +214,17 @@ impl Action for ConfigureInitService {
.expect("service_name should be set for Launchd");
let domain = DARWIN_LAUNCHD_DOMAIN;

tokio::fs::copy(&service_src, service_dest)
.await
.map_err(|e| {
Self::error(ActionErrorKind::Copy(
service_src.clone(),
PathBuf::from(service_dest),
e,
))
})?;
if let Some(service_src) = service_src {
tokio::fs::copy(&service_src, service_dest)
.await
.map_err(|e| {
Self::error(ActionErrorKind::Copy(
service_src.clone(),
PathBuf::from(service_dest),
e,
))
})?;
}

execute_command(
Command::new("launchctl")
Expand Down

0 comments on commit 75c3e93

Please sign in to comment.