Skip to content

Commit cd2727e

Browse files
authored
[GUI] Fix Updater (#1095)
2 parents aa9bf3c + 95ea117 commit cd2727e

File tree

9 files changed

+56
-16
lines changed

9 files changed

+56
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/packages/owmods-gui.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}:
1919
rustPlatform.buildRustPackage rec {
2020
pname = "owmods-gui";
21-
version = "0.15.2";
21+
version = "0.15.3";
2222

2323
VITE_VERSION_SUFFIX = "-nix";
2424

owmods_gui/backend/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "owmods_gui"
33
authors = ["Bwc9876 <bwc9876@outerwildsmods.com>"]
44
description = "A GUI Tool To Manage OWML Mods"
5-
version = "0.15.2"
5+
version = "0.15.3"
66
readme = "./README.md"
77
repository = "https://github.com/ow-mods/ow-mod-man/"
88
license = "GPL-3.0-or-later"
@@ -28,13 +28,13 @@ time = { version = "0.3.41", features = ["macros", "local-offset"] }
2828
opener = "0.8.2"
2929
tauri-plugin-deep-link = "2.4.0"
3030
tauri-plugin-single-instance = { version = "2.3.0", features = ["deep-link"] }
31-
tauri-plugin-dialog = "2.3.0"
31+
tauri-plugin-dialog = "2.3.1"
3232
tauri-plugin-updater = "2.9.0"
3333
tauri-plugin-os = "2.3.0"
3434
tauri-plugin-shell = "2.3.0"
3535
tauri-plugin-process = "2.3.0"
3636
tauri-plugin-clipboard-manager = "2.3.0"
37-
tauri-plugin-window-state = "2.3.0"
37+
tauri-plugin-window-state = "2.4.0"
3838

3939

4040
[features]

owmods_gui/backend/capabilities/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"core:event:default",
1616
"deep-link:default",
1717
"dialog:default",
18-
"shell:allow-open"
18+
"shell:allow-open",
19+
"updater:default"
1920
]
2021
}

owmods_gui/backend/src/main.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use owmods_core::{
1818
progress::bars::ProgressBars,
1919
protocol::ProtocolPayload,
2020
};
21+
use tauri::AppHandle;
22+
use tauri_plugin_updater::UpdaterExt;
2123

2224
use anyhow::anyhow;
2325
use time::macros::format_description;
@@ -93,6 +95,39 @@ pub struct State {
9395
mods_in_progress: StatePart<Vec<String>>,
9496
}
9597

98+
async fn update(app: AppHandle) -> tauri_plugin_updater::Result<()> {
99+
log::debug!("Checking for Manager Updates");
100+
if let Some(update) = app.updater()?.check().await? {
101+
let mut bytes: usize = 0;
102+
let mut last_debounce: usize = 0;
103+
log::info!("Manager Update Found! (${})", update.version);
104+
update
105+
.download_and_install(
106+
|recv, tot| {
107+
bytes = bytes.saturating_add(recv);
108+
let debounce = bytes / 1000000;
109+
if last_debounce != debounce {
110+
last_debounce = debounce;
111+
log::debug!(
112+
"Download Update ({}/{})",
113+
bytes / 1000,
114+
tot.unwrap_or(u64::MAX) / 1000
115+
);
116+
}
117+
},
118+
|| {
119+
log::debug!("Download complete! Installing");
120+
},
121+
)
122+
.await?;
123+
log::info!("Manager Update Complete");
124+
Ok(())
125+
} else {
126+
log::debug!("No Manager Updates");
127+
Ok(())
128+
}
129+
}
130+
96131
fn main() -> Result<(), Box<dyn Error>> {
97132
let config = Config::get(None).unwrap_or(Config::default(None)?);
98133
let gui_config = GuiConfig::get().unwrap_or_default();
@@ -144,6 +179,18 @@ fn main() -> Result<(), Box<dyn Error>> {
144179
debug!("Setup window state");
145180
}
146181

182+
// Update Setup
183+
let update_handle = app.handle().clone();
184+
185+
tauri::async_runtime::spawn(async {
186+
update_handle
187+
.plugin(tauri_plugin_updater::Builder::new().build())
188+
.unwrap();
189+
if let Err(why) = update(update_handle).await {
190+
warn!("Failed to update: {why:?}");
191+
}
192+
});
193+
147194
// Protocol Listener Setup
148195

149196
protocol::prep_protocol(app.handle().clone());

owmods_gui/backend/tauri.conf.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"open": "(^https://(www\\.)?(github.com|outerwildsmods.com|paypal.me|patreon.com|buymeacoffee.com|cash.app|ko-fi.com)/)|(^https://(www\\.)?discord.gg/wusTQYbYTc$)"
1919
},
2020
"updater": {
21-
"active": true,
2221
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkzRURBNzdENEVCREU1NDYKUldSRzViMU9mYWZ0azRoODZIdmVGWUZxVTNQRUVXU2hOTllqcGM4N2RRNjFEN2N3cnhXbW45V0sK",
2322
"windows": {
2423
"installMode": "basicUi"

owmods_gui/backend/tauri.linux.conf.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

owmods_gui/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "owmods-gui-frontend",
33
"private": true,
4-
"version": "0.15.2",
4+
"version": "0.15.3",
55
"type": "module",
66
"engines": {
77
"npm": ">=10.0.0",

owmods_gui/frontend/src/components/main/AppAlert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const AppAlert = memo(function AppAlert() {
5353
commands.dismissAlert({ alert: alert! });
5454
}, [alert]);
5555

56-
if (alert === null || !alert.enabled) {
56+
if (alert === null || alert.message?.startsWith("<0.15.3:") || !alert.enabled) {
5757
return <></>;
5858
}
5959

0 commit comments

Comments
 (0)