From 14b0e96c7dc14ac5d59e0dbf84e1dd35c3a0e20d Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Mon, 8 Dec 2025 13:19:27 -0400 Subject: [PATCH] trying fix macos download --- src-tauri/src/binary_manager.rs | 42 +++++++++++++++++++++++++++++++++ src-tauri/src/downloader.rs | 2 ++ 2 files changed, 44 insertions(+) diff --git a/src-tauri/src/binary_manager.rs b/src-tauri/src/binary_manager.rs index ba05233..3c188ed 100644 --- a/src-tauri/src/binary_manager.rs +++ b/src-tauri/src/binary_manager.rs @@ -95,6 +95,17 @@ pub async fn download_ytdlp(app: &AppHandle) -> Result { fs::set_permissions(&path, perms)?; } + #[cfg(target_os = "macos")] + { + // Remove quarantine attribute to allow execution on macOS + std::process::Command::new("xattr") + .arg("-d") + .arg("com.apple.quarantine") + .arg(&path) + .output() + .ok(); + } + Ok(path) } @@ -241,6 +252,17 @@ pub async fn download_qjs(app: &AppHandle) -> Result { fs::set_permissions(&final_path, perms)?; } + #[cfg(target_os = "macos")] + { + // Remove quarantine attribute to allow execution on macOS + std::process::Command::new("xattr") + .arg("-d") + .arg("com.apple.quarantine") + .arg(&final_path) + .output() + .ok(); + } + Ok(final_path) } @@ -262,11 +284,31 @@ pub async fn ensure_binaries(app: &AppHandle) -> Result<()> { let ytdlp = get_ytdlp_path(app)?; if !ytdlp.exists() { download_ytdlp(app).await?; + } else { + #[cfg(target_os = "macos")] + { + std::process::Command::new("xattr") + .arg("-d") + .arg("com.apple.quarantine") + .arg(&ytdlp) + .output() + .ok(); + } } let qjs = get_qjs_path(app)?; if !qjs.exists() { download_qjs(app).await?; + } else { + #[cfg(target_os = "macos")] + { + std::process::Command::new("xattr") + .arg("-d") + .arg("com.apple.quarantine") + .arg(&qjs) + .output() + .ok(); + } } Ok(()) diff --git a/src-tauri/src/downloader.rs b/src-tauri/src/downloader.rs index b9acb60..2eda286 100644 --- a/src-tauri/src/downloader.rs +++ b/src-tauri/src/downloader.rs @@ -70,6 +70,7 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool cmd.creation_flags(0x08000000); // Pass the runtime and its absolute path to --js-runtimes + // Rust's Command automatically handles spaces in arguments, so we should NOT quote the path here. cmd.arg("--js-runtimes").arg(format!("quickjs:{}", qjs_path.to_string_lossy())); cmd.arg("--dump-single-json") @@ -170,6 +171,7 @@ pub async fn download_video( // Pass the runtime and its absolute path to --js-runtimes args.push("--js-runtimes".to_string()); + // Rust's Command automatically handles spaces in arguments, so we should NOT quote the path here. args.push(format!("quickjs:{}", qjs_path.to_string_lossy())); args.push(url);