From 75c3e93a2185e417c849eca343a5cf812af774a9 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 31 Jul 2024 08:58:32 -0400 Subject: [PATCH] configure_init_service: only try to copy the service src if one is provided, since it may not be (#1068) --- src/action/common/configure_init_service.rs | 24 ++++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/action/common/configure_init_service.rs b/src/action/common/configure_init_service.rs index 6c1fa0ef9..abeae902d 100644 --- a/src/action/common/configure_init_service.rs +++ b/src/action/common/configure_init_service.rs @@ -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"); @@ -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")