pull/1991/head
jLynx 9 months ago
parent a8866b9533
commit 337e23eb78

@ -63,6 +63,8 @@ pub enum Error {
TempDirNotOnSameMountPoint, TempDirNotOnSameMountPoint,
#[error("binary for the current target not found in the archive")] #[error("binary for the current target not found in the archive")]
BinaryNotFoundInArchive, BinaryNotFoundInArchive,
#[error("failed to create temporary directory")]
TempDirNotFound,
#[error("Authentication failed or was cancelled")] #[error("Authentication failed or was cancelled")]
AuthenticationFailed, AuthenticationFailed,
#[error("Failed to install .deb package")] #[error("Failed to install .deb package")]

@ -765,14 +765,14 @@ impl Update {
/// ///
fn install_inner(&self, bytes: &[u8]) -> Result<()> { fn install_inner(&self, bytes: &[u8]) -> Result<()> {
if self.is_deb_package() { if self.is_deb_package() {
self.install_deb_update(bytes) self.install_deb(bytes)
} else { } else {
// Handle AppImage or other formats // Handle AppImage or other formats
self.install_appimage_update(bytes) self.install_appimage(bytes)
} }
} }
fn install_appimage_update(&self, bytes: &[u8]) -> Result<()> { fn install_appimage(&self, bytes: &[u8]) -> Result<()> {
use std::os::unix::fs::{MetadataExt, PermissionsExt}; use std::os::unix::fs::{MetadataExt, PermissionsExt};
let extract_path_metadata = self.extract_path.metadata()?; let extract_path_metadata = self.extract_path.metadata()?;
@ -876,11 +876,19 @@ impl Update {
dpkg_exists && apt_exists && package_in_dpkg dpkg_exists && apt_exists && package_in_dpkg
} }
fn install_deb_update(&self, bytes: &[u8]) -> Result<()> { fn install_deb(&self, bytes: &[u8]) -> Result<()> {
// Create a temporary directory // Try different temp directories, similar to AppImage handling
let tmp_dir = tempfile::Builder::new() let tmp_dir_locations = ["/tmp", "/var/tmp", "/dev/shm"];
.prefix("tauri_deb_update")
.tempdir_in("/tmp")?; let tmp_dir = tmp_dir_locations
.iter()
.find_map(|dir| {
tempfile::Builder::new()
.prefix("tauri_deb_update")
.tempdir_in(dir)
.ok()
})
.ok_or_else(|| Error::TempDirNotFound)?;
let deb_path = tmp_dir.path().join("package.deb"); let deb_path = tmp_dir.path().join("package.deb");
@ -890,9 +898,6 @@ impl Update {
// Try different privilege escalation methods // Try different privilege escalation methods
let installation_result = self.try_install_with_privileges(&deb_path); let installation_result = self.try_install_with_privileges(&deb_path);
// Clean up
let _ = std::fs::remove_file(&deb_path);
installation_result installation_result
} }

Loading…
Cancel
Save