mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +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]
|
||||
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"
|
||||
|
||||
[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.
|
||||
#[error("temp directory is not on the same mount point as the AppImage")]
|
||||
TempDirNotOnSameMountPoint,
|
||||
#[error("binary for the current target not found in the archive")]
|
||||
BinaryNotFoundInAcrhive,
|
||||
#[error(transparent)]
|
||||
Http(#[from] http::Error),
|
||||
}
|
||||
|
||||
@@ -600,6 +600,7 @@ impl Update {
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn install_inner(&self, bytes: Vec<u8>) -> Result<()> {
|
||||
use flate2::read::GzDecoder;
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
os::unix::fs::{MetadataExt, PermissionsExt},
|
||||
@@ -632,7 +633,8 @@ impl Update {
|
||||
|
||||
// extract the buffer to the tmp_dir
|
||||
// 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() {
|
||||
if let Ok(path) = entry.path() {
|
||||
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