mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
fix(updater): fix appimage extraction (#784)
* fix updater on linux * review changes * Apply suggestions from code review * change file --------- Co-authored-by: Kris Krolak <krzysiek.krolak@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"updater": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix updater failing to extract the AppImage resulting in failing to update and also deleting the current version.
|
||||||
@@ -34,7 +34,7 @@ tar = "0.4"
|
|||||||
[target."cfg(target_os = \"windows\")".dependencies]
|
[target."cfg(target_os = \"windows\")".dependencies]
|
||||||
zip = { version = "0.6", default-features = false }
|
zip = { version = "0.6", default-features = false }
|
||||||
|
|
||||||
[target."cfg(target_os = \"macos\")".dependencies]
|
[target."cfg(any(target_os = \"macos\", target_os = \"linux\"))".dependencies]
|
||||||
flate2 = "1.0.27"
|
flate2 = "1.0.27"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ pub enum Error {
|
|||||||
/// Temp dir is not on same mount mount. This prevents our updater to rename the AppImage to a temp file.
|
/// Temp dir is not on same mount mount. This prevents our updater to rename the AppImage to a temp file.
|
||||||
#[error("temp directory is not on the same mount point as the AppImage")]
|
#[error("temp directory is not on the same mount point as the AppImage")]
|
||||||
TempDirNotOnSameMountPoint,
|
TempDirNotOnSameMountPoint,
|
||||||
|
#[error("binary for the current target not found in the archive")]
|
||||||
|
BinaryNotFoundInAcrhive,
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Http(#[from] http::Error),
|
Http(#[from] http::Error),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,6 +600,7 @@ impl Update {
|
|||||||
target_os = "openbsd"
|
target_os = "openbsd"
|
||||||
))]
|
))]
|
||||||
fn install_inner(&self, bytes: Vec<u8>) -> Result<()> {
|
fn install_inner(&self, bytes: Vec<u8>) -> Result<()> {
|
||||||
|
use flate2::read::GzDecoder;
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
os::unix::fs::{MetadataExt, PermissionsExt},
|
os::unix::fs::{MetadataExt, PermissionsExt},
|
||||||
@@ -632,7 +633,8 @@ impl Update {
|
|||||||
|
|
||||||
// extract the buffer to the tmp_dir
|
// extract the buffer to the tmp_dir
|
||||||
// we extract our signed archive into our final directory without any temp file
|
// we extract our signed archive into our final directory without any temp file
|
||||||
let mut archive = tar::Archive::new(archive);
|
let decoder = GzDecoder::new(archive);
|
||||||
|
let mut archive = tar::Archive::new(decoder);
|
||||||
for mut entry in archive.entries()?.flatten() {
|
for mut entry in archive.entries()?.flatten() {
|
||||||
if let Ok(path) = entry.path() {
|
if let Ok(path) = entry.path() {
|
||||||
if path.extension() == Some(OsStr::new("AppImage")) {
|
if path.extension() == Some(OsStr::new("AppImage")) {
|
||||||
@@ -646,8 +648,10 @@ impl Update {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if we have not returned early we should restore the backup
|
||||||
|
std::fs::rename(tmp_app_image, &self.extract_path)?;
|
||||||
|
|
||||||
return Ok(());
|
return Err(Error::BinaryNotFoundInAcrhive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user