diff --git a/.changes/updater-appimage.md b/.changes/updater-appimage.md new file mode 100644 index 00000000..212a9859 --- /dev/null +++ b/.changes/updater-appimage.md @@ -0,0 +1,5 @@ +--- +"updater": patch +--- + +Fix updater failing to extract the AppImage resulting in failing to update and also deleting the current version. diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index 272d063a..fa3235be 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -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] diff --git a/plugins/updater/src/error.rs b/plugins/updater/src/error.rs index f12a7e12..704c4721 100644 --- a/plugins/updater/src/error.rs +++ b/plugins/updater/src/error.rs @@ -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), } diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index 3b93beef..a4d5ef6a 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -600,6 +600,7 @@ impl Update { target_os = "openbsd" ))] fn install_inner(&self, bytes: Vec) -> 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); } } }