Merge 5eae160c6d
into 80d4d8e128
commit
1e9c1cc89a
@ -1,57 +1,56 @@
|
|||||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
use tauri_plugin_updater::UpdaterExt;
|
use tauri_plugin_updater::UpdaterExt;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut context = tauri::generate_context!();
|
let mut context = tauri::generate_context!();
|
||||||
|
tauri::Builder::default()
|
||||||
tauri::Builder::default()
|
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
.setup(|app| {
|
||||||
.setup(|app| {
|
let handle = app.handle().clone();
|
||||||
let handle = app.handle().clone();
|
tauri::async_runtime::spawn(async move {
|
||||||
tauri::async_runtime::spawn(async move {
|
let mut builder = handle.updater_builder();
|
||||||
let mut builder = handle.updater_builder();
|
if std::env::var("TARGET").unwrap_or_default() == "nsis" {
|
||||||
if std::env::var("TARGET").unwrap_or_default() == "nsis" {
|
// /D sets the default installation directory ($INSTDIR),
|
||||||
// /D sets the default installation directory ($INSTDIR),
|
// overriding InstallDir and InstallDirRegKey.
|
||||||
// overriding InstallDir and InstallDirRegKey.
|
// It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces.
|
||||||
// It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces.
|
// Only absolute paths are supported.
|
||||||
// Only absolute paths are supported.
|
// NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder
|
||||||
// NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder
|
builder = builder.installer_args(vec![format!(
|
||||||
builder = builder.installer_args(vec![format!(
|
"/D={}",
|
||||||
"/D={}",
|
tauri::utils::platform::current_exe()
|
||||||
tauri::utils::platform::current_exe()
|
.unwrap()
|
||||||
.unwrap()
|
.parent()
|
||||||
.parent()
|
.unwrap()
|
||||||
.unwrap()
|
.display()
|
||||||
.display()
|
)]);
|
||||||
)]);
|
}
|
||||||
}
|
let updater = builder.build().unwrap();
|
||||||
let updater = builder.build().unwrap();
|
|
||||||
|
match updater.check().await {
|
||||||
match updater.check().await {
|
Ok(Some(update)) => {
|
||||||
Ok(Some(update)) => {
|
if let Err(e) = update.download_and_install(|_, _| {}, || {}).await {
|
||||||
if let Err(e) = update.download_and_install(|_, _| {}, || {}).await {
|
println!("{e}");
|
||||||
println!("{e}");
|
std::process::exit(1);
|
||||||
std::process::exit(1);
|
}
|
||||||
}
|
std::process::exit(0);
|
||||||
std::process::exit(0);
|
}
|
||||||
}
|
Ok(None) => {
|
||||||
Ok(None) => {
|
std::process::exit(2);
|
||||||
std::process::exit(2);
|
}
|
||||||
}
|
Err(e) => {
|
||||||
Err(e) => {
|
println!("{e}");
|
||||||
println!("{e}");
|
std::process::exit(1);
|
||||||
std::process::exit(1);
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
Ok(())
|
||||||
Ok(())
|
})
|
||||||
})
|
.run(context)
|
||||||
.run(context)
|
.expect("error while running tauri application");
|
||||||
.expect("error while running tauri application");
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in new issue