fix: Linux deb updater temp file deleted before dpkg install#55
Conversation
NamedTempFile::into_file() consumes the handle and deletes the file from disk. dpkg then fails with "No such file or directory". Use keep() instead to persist the file, and clean it up manually after. Also fix compiler warning: cast function pointer via *const () first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes the Linux deb/rpm self-update flow in the Tauri backend by ensuring the downloaded package temp file remains present on disk long enough for dpkg/rpm to read it, and addresses a Rust compiler warning related to function-pointer casting in the Linux crash handler.
Changes:
- Persist updater temp file on disk using
NamedTempFile::keep()sodpkg/rpmcan install from the filesystem path. - Manually delete the updater temp file after installation completes.
- Adjust SIG handler function-pointer cast to avoid the warning by casting via
*const ()first.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/desktop/src-tauri/src/lib.rs | Adjusts Linux crash-handler sigaction assignment to avoid a function-pointer cast warning. |
| apps/desktop/src-tauri/src/commands.rs | Changes Linux package update download temp-file handling to persist on disk for dpkg/rpm, with manual cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // keep() persists the file on disk (disables auto-delete) so dpkg/rpm can access it by path. | ||
| let (std_file, tmp_path) = temp_file.keep().map_err(|e| format!("Failed to persist temp file: {e}"))?; | ||
| let mut file = tokio::fs::File::from_std(std_file); |
There was a problem hiding this comment.
After switching to temp_file.keep(), the temp package file will persist on disk for any early-return error after this point (download stream error, write/flush error, pkexec spawn failure), because the cleanup only happens after output() completes. Consider adding a scope guard / TempPath-style RAII cleanup so the file is removed on all error paths, and only optionally retained for debugging when installation fails.
Use into_parts() to get a TempPath (RAII auto-delete on drop) instead of keep(). The file is cleaned up on download errors, write errors, and install failures — not just the success path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NamedTempFile::into_file() consumes the handle and deletes the file from disk. dpkg then fails with "No such file or directory". Use keep() instead to persist the file, and clean it up manually after.
Also fix compiler warning: cast function pointer via *const () first.