diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 25c18ca..0d9950e 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -1233,14 +1233,17 @@ pub async fn package_update(app: AppHandle) -> Result<(), String> let total_size = response.content_length().unwrap_or(0); let extension = if info.install_type == "rpm" { "rpm" } else { "deb" }; + // keep() disables auto-delete and returns a TempPath (RAII: deletes on drop) + // plus the raw File handle for writing. TempPath stays alive until end of + // function, so dpkg/rpm can access the file, and cleanup happens on all paths. use tempfile::Builder; let temp_file = Builder::new() .prefix("maxvideoplayer_update.") .suffix(&format!(".{extension}")) .tempfile_in(std::env::temp_dir()) .map_err(|e| format!("Failed to create temp file: {e}"))?; - let tmp_path = temp_file.path().to_path_buf(); - let mut file = tokio::fs::File::from_std(temp_file.into_file()); + let (std_file, tmp_path) = temp_file.into_parts(); + let mut file = tokio::fs::File::from_std(std_file); let mut stream = response.bytes_stream(); let mut downloaded: u64 = 0; @@ -1285,8 +1288,7 @@ pub async fn package_update(app: AppHandle) -> Result<(), String> _ => unreachable!(), }; - // Clean up temp file - let _ = std::fs::remove_file(&tmp_path); + // tmp_path (TempPath) auto-deletes on drop at end of function. if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index 59019ca..02471ff 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -31,7 +31,7 @@ fn install_crash_handler() { let mut action: libc::sigaction = std::mem::zeroed(); action.sa_flags = libc::SA_RESETHAND; - action.sa_sigaction = crash_handler as usize; + action.sa_sigaction = crash_handler as *const () as usize; libc::sigemptyset(&mut action.sa_mask); libc::sigaction(libc::SIGSEGV, &action, std::ptr::null_mut());