|
|
|
@ -840,9 +840,15 @@ impl Update {
|
|
|
|
|
/// MacOS
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
impl Update {
|
|
|
|
|
/// ### Expected structure:
|
|
|
|
|
/// ├── [AppName]_[version]_x64.app.tar.gz # GZ generated by tauri-bundler
|
|
|
|
|
/// │ └──[AppName].app # Main application
|
|
|
|
|
/// │ └── Contents # Application contents...
|
|
|
|
|
/// │ └── ...
|
|
|
|
|
/// └── ...
|
|
|
|
|
fn install_inner(&self, bytes: &[u8]) -> Result<()> {
|
|
|
|
|
use flate2::read::GzDecoder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cursor = Cursor::new(bytes);
|
|
|
|
|
let mut extracted_files: Vec<PathBuf> = Vec::new();
|
|
|
|
|
|
|
|
|
@ -850,7 +856,7 @@ impl Update {
|
|
|
|
|
let tmp_backup_dir = tempfile::Builder::new()
|
|
|
|
|
.prefix("tauri_current_app")
|
|
|
|
|
.tempdir()?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let tmp_extract_dir = tempfile::Builder::new()
|
|
|
|
|
.prefix("tauri_updated_app")
|
|
|
|
|
.tempdir()?;
|
|
|
|
@ -878,7 +884,10 @@ impl Update {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Try to move the current app to backup
|
|
|
|
|
let move_result = std::fs::rename(&self.extract_path, tmp_backup_dir.path().join("current_app"));
|
|
|
|
|
let move_result = std::fs::rename(
|
|
|
|
|
&self.extract_path,
|
|
|
|
|
tmp_backup_dir.path().join("current_app"),
|
|
|
|
|
);
|
|
|
|
|
let need_authorization = if let Err(err) = move_result {
|
|
|
|
|
if err.kind() == std::io::ErrorKind::PermissionDenied {
|
|
|
|
|
true
|
|
|
|
@ -897,10 +906,10 @@ impl Update {
|
|
|
|
|
src = self.extract_path.display(),
|
|
|
|
|
new = tmp_extract_dir.path().display()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut osascript = std::process::Command::new("osascript");
|
|
|
|
|
osascript.arg("-e").arg(script);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let status = osascript.status()?;
|
|
|
|
|
if !status.success() {
|
|
|
|
|
std::fs::remove_dir_all(tmp_extract_dir.path()).ok();
|
|
|
|
|