Skip to content

Commit

Permalink
minor bug fix for updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Dec 22, 2023
1 parent 49c71ed commit 06c5f1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
34 changes: 11 additions & 23 deletions src-tauri/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ pub fn check_for_updates<R: Runtime>(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.
Expand Down Expand Up @@ -190,29 +201,6 @@ pub fn check_for_updates<R: Runtime>(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(_) => {}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/UpdaterStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 06c5f1c

Please sign in to comment.