-
-
Notifications
You must be signed in to change notification settings - Fork 0
Push back to dev #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push back to dev #56
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1233,14 +1233,17 @@ pub async fn package_update<R: Runtime>(app: AppHandle<R>) -> 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<R: Runtime>(app: AppHandle<R>) -> 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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; | ||||||
|
||||||
| action.sa_sigaction = crash_handler as *const () as usize; | |
| action.sa_sigaction = crash_handler as libc::sighandler_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are inaccurate: this code uses
into_parts(), notkeep(). Intempfile,keep()typically disables auto-delete and returns a persisted path, whileinto_parts()returns aTempPaththat deletes on drop. Please update the comment to describeinto_parts()/TempPathbehavior so future maintainers don’t misunderstand the cleanup semantics.