From 06c5f1ccbd6fc5542ac67d9ede2fb78504b7de50 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Fri, 22 Dec 2023 01:09:43 -0500 Subject: [PATCH] minor bug fix for updater --- src-tauri/src/updater.rs | 34 +++++++++++----------------------- src/stores/UpdaterStore.ts | 2 +- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src-tauri/src/updater.rs b/src-tauri/src/updater.rs index ab28ffb1..d27bc625 100644 --- a/src-tauri/src/updater.rs +++ b/src-tauri/src/updater.rs @@ -40,6 +40,17 @@ pub fn check_for_updates(ignore_prereleases: bool, window: tauri::Wi } } + let package_path = handle + .path() + .app_local_data_dir() + .unwrap() + .join("update.sbcup"); + + // if we already have an update package, remove it + if package_path.exists() { + clear_update_cache(window.clone()); + } + tauri::async_runtime::spawn(async move { println!("[Updater] Searching for update file on github."); // Custom configure the updater. @@ -190,29 +201,6 @@ pub fn check_for_updates(ignore_prereleases: bool, window: tauri::Wi // } UPDATE_INFO.lock().unwrap().replace(update.clone()); - let package_path = handle - .path() - .app_local_data_dir() - .unwrap() - .join("update.sbcup"); - - // if we already have an update package, emit the update downloaded event - if package_path.exists() { - match window.emit( - "UPDATE_DOWNLOADED", - Some(UpdateAvailable { - version: update.version.clone(), - body: update.body.clone(), - }), - ) { - Ok(_) => {} - Err(e) => { - println!("[Updater] Failed to emit update downloaded event: {:?}", e); - } - } - return; - } - // otherwise emit the update available event match window.emit("UPDATE_AVAILABLE", Some({})) { Ok(_) => {} diff --git a/src/stores/UpdaterStore.ts b/src/stores/UpdaterStore.ts index 990c2d46..705ad8d0 100644 --- a/src/stores/UpdaterStore.ts +++ b/src/stores/UpdaterStore.ts @@ -126,7 +126,7 @@ export default class UpdaterStore { } async quitAndInstall() { - if (!this.updateAvailable) { + if (!this.updateDownloaded) { this.logger.warn("No update is pending installation"); return; }