mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
Co-authored-by: Lucas Nogueira <lucas@tauri.app> fix(updater): installation on macos #591 fix(updater): use zip flate2 feature #591 fix(updater): use zip flate2 feature #591"
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"updater": patch
|
||||
---
|
||||
|
||||
Fixes update on macOS.
|
||||
Generated
+3
-2
@@ -1688,9 +1688,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.26"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
|
||||
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
@@ -5997,6 +5997,7 @@ version = "2.0.0-alpha.2"
|
||||
dependencies = [
|
||||
"base64 0.21.2",
|
||||
"dirs-next",
|
||||
"flate2",
|
||||
"futures-util",
|
||||
"http",
|
||||
"minisign-verify",
|
||||
|
||||
@@ -33,6 +33,10 @@ tar = "0.4"
|
||||
[target."cfg(target_os = \"windows\")".dependencies]
|
||||
zip = { version = "0.6", default-features = false }
|
||||
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
flate2 = "1.0.27"
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
mockito = "0.31"
|
||||
|
||||
|
||||
@@ -661,7 +661,9 @@ impl Update {
|
||||
// └── ...
|
||||
#[cfg(target_os = "macos")]
|
||||
fn install_inner(&self, bytes: Vec<u8>) -> Result<()> {
|
||||
let archive = Cursor::new(bytes);
|
||||
use flate2::read::GzDecoder;
|
||||
|
||||
let cursor = Cursor::new(bytes);
|
||||
let mut extracted_files: Vec<PathBuf> = Vec::new();
|
||||
|
||||
// the first file in the tar.gz will always be
|
||||
@@ -673,29 +675,33 @@ impl Update {
|
||||
// create backup of our current app
|
||||
std::fs::rename(&self.extract_path, tmp_dir.path())?;
|
||||
|
||||
let mut archive = tar::Archive::new(archive);
|
||||
for mut entry in archive.entries()?.flatten() {
|
||||
if let Ok(path) = entry.path() {
|
||||
// skip the first folder (should be the app name)
|
||||
let collected_path: PathBuf = path.iter().skip(1).collect();
|
||||
let extraction_path = &self.extract_path.join(collected_path);
|
||||
let decoder = GzDecoder::new(cursor);
|
||||
let mut archive = tar::Archive::new(decoder);
|
||||
|
||||
// if something went wrong during the extraction, we should restore previous app
|
||||
if let Err(err) = entry.unpack(extraction_path) {
|
||||
for file in &extracted_files {
|
||||
// delete all the files we extracted
|
||||
if file.is_dir() {
|
||||
std::fs::remove_dir(file)?;
|
||||
} else {
|
||||
std::fs::remove_file(file)?;
|
||||
}
|
||||
std::fs::create_dir(&self.extract_path)?;
|
||||
|
||||
for entry in archive.entries()? {
|
||||
let mut entry = entry?;
|
||||
|
||||
// skip the first folder (should be the app name)
|
||||
let collected_path: PathBuf = entry.path()?.iter().skip(1).collect();
|
||||
let extraction_path = &self.extract_path.join(collected_path);
|
||||
|
||||
// if something went wrong during the extraction, we should restore previous app
|
||||
if let Err(err) = entry.unpack(extraction_path) {
|
||||
for file in extracted_files.iter().rev() {
|
||||
// delete all the files we extracted
|
||||
if file.is_dir() {
|
||||
std::fs::remove_dir(file)?;
|
||||
} else {
|
||||
std::fs::remove_file(file)?;
|
||||
}
|
||||
std::fs::rename(tmp_dir.path(), &self.extract_path)?;
|
||||
return Err(err.into());
|
||||
}
|
||||
|
||||
extracted_files.push(extraction_path.to_path_buf());
|
||||
std::fs::rename(tmp_dir.path(), &self.extract_path)?;
|
||||
return Err(err.into());
|
||||
}
|
||||
|
||||
extracted_files.push(extraction_path.to_path_buf());
|
||||
}
|
||||
|
||||
let _ = std::process::Command::new("touch")
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"updater": {
|
||||
"active": true,
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK",
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEMwNjY1MEExMTFBMDU5RTUKUldUbFdhQVJvVkJtd09sZ1ROT25yVGFhU2o0ZnUyd1FlT0ZTQ2ZXamN3SXk4SjZLZmNwRnV5dTMK",
|
||||
"windows": {
|
||||
"installMode": "quiet"
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::{
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
const UPDATER_PRIVATE_KEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==";
|
||||
const UPDATER_PRIVATE_KEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5Qm9uUXIyeEM2YkczeGMwZDFENmw1WHEzaFk5aDlOOXNyTWRxRnY4UUpzZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQTVWbWdFYUZRWnNDZmdyUW9ibWExVEFTY0pVTWpVS2xlOHdhR1I3Q3hpd2FTNjg1MXZENEQyZWxnVE5PbnJUYWFTajRmdTJ3UWVPRlNDZldqY3dJeThKNktmY3BGdXl1M1BPdHgwOFhIQzJLSnpqS0Z2cVdmaEs2WWRmK3d4SHVCMlpHVGduaVAzclU9Cg==";
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct PackageConfig {
|
||||
@@ -72,8 +72,8 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa
|
||||
command.args(["--bundles", "msi", "nsis"]);
|
||||
|
||||
command
|
||||
.env("TAURI_PRIVATE_KEY", UPDATER_PRIVATE_KEY)
|
||||
.env("TAURI_KEY_PASSWORD", "")
|
||||
.env("TAURI_SIGNING_PRIVATE_KEY", UPDATER_PRIVATE_KEY)
|
||||
.env("TAURI_SIGNING_PRIVATE_KEY_PASSWORD", "")
|
||||
.args(["--bundles", "updater"]);
|
||||
} else {
|
||||
#[cfg(windows)]
|
||||
|
||||
Reference in New Issue
Block a user