Skip to content

Push back to dev#56

Merged
MaxMB15 merged 3 commits into
devfrom
main
Apr 6, 2026
Merged

Push back to dev#56
MaxMB15 merged 3 commits into
devfrom
main

Conversation

@MaxMB15

@MaxMB15 MaxMB15 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

No description provided.

MaxMB15 and others added 3 commits April 6, 2026 12:56
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>
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>
fix: Linux deb updater temp file deleted before dpkg install
Copilot AI review requested due to automatic review settings April 6, 2026 11:12
@MaxMB15 MaxMB15 merged commit 8115b0d into dev Apr 6, 2026
5 of 8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adjusts low-level platform integration in the Tauri desktop app by fixing a signal handler cast and improving temporary file lifecycle management during package updates.

Changes:

  • Update sigaction.sa_sigaction assignment to use an explicit pointer-to-integer cast.
  • Rework package update temp file handling to keep the path alive (RAII) and rely on auto-cleanup rather than manual deletion.
  • Add inline documentation explaining the temp file lifetime/cleanup approach.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/desktop/src-tauri/src/lib.rs Updates signal handler casting for sigaction setup.
apps/desktop/src-tauri/src/commands.rs Uses NamedTempFile::into_parts() and TempPath to ensure the update artifact is cleaned up via RAII instead of manual remove_file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1236 to +1238
// 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.

Copilot AI Apr 6, 2026

Copy link

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(), not keep(). In tempfile, keep() typically disables auto-delete and returns a persisted path, while into_parts() returns a TempPath that deletes on drop. Please update the comment to describe into_parts()/TempPath behavior so future maintainers don’t misunderstand the cleanup semantics.

Suggested change
// 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.
// into_parts() splits the NamedTempFile into the raw File handle plus a
// TempPath. Keeping TempPath alive preserves the path for dpkg/rpm to read,
// and the temp file is still deleted automatically when TempPath is dropped.

Copilot uses AI. Check for mistakes.
.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();

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmp_path is now a TempPath (RAII handle), not a plain PathBuf. Consider renaming to something like temp_path or temp_path_handle to reduce confusion and make the drop-based deletion behavior more obvious.

Copilot uses AI. Check for mistakes.
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;

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting a function to *const () and then to usize is a brittle way to populate sa_sigaction and obscures the intended ABI/type. Prefer assigning using the libc-provided handler type (e.g., libc::sighandler_t where available) or a clearly documented, platform-appropriate conversion, so this remains portable across targets where the field type/layout differs.

Suggested change
action.sa_sigaction = crash_handler as *const () as usize;
action.sa_sigaction = crash_handler as libc::sighandler_t;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants