From b76fc2415625f5c8fa6ba7ea9b02c770c177a26f Mon Sep 17 00:00:00 2001 From: Fantix King Date: Sun, 15 Sep 2024 11:57:12 -0400 Subject: [PATCH] Try to fix macOS bursting bubbles issue --- src/portable/macos.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/portable/macos.rs b/src/portable/macos.rs index 4a0b58383..bd67b4b40 100644 --- a/src/portable/macos.rs +++ b/src/portable/macos.rs @@ -137,16 +137,25 @@ fn plist_data(name: &str, info: &InstanceInfo) -> anyhow::Result { )) } +fn create_dir_all_if_not_exists>(path: P) -> std::io::Result<()> { + let path = path.as_ref(); + if path.exists() { + Ok(()) + } else { + fs::create_dir_all(path) + } +} + fn _create_service(info: &InstanceInfo) -> anyhow::Result<()> { let name = &info.name; let plist_dir_path = plist_dir()?; - fs::create_dir_all(&plist_dir_path)?; + create_dir_all_if_not_exists(&plist_dir_path)?; let plist_path = plist_dir_path.join(plist_name(name)); let unit_name = launchd_name(name); fs::write(&plist_path, plist_data(name, info)?)?; if let Some(dir) = runstate_dir(name)?.parent() { - fs::create_dir_all(dir)?; + create_dir_all_if_not_exists(dir)?; } // Clear the disabled status of the unit name, in case the user disabled