@@ -88,7 +88,8 @@ final class Updater: ObservableObject {
8888 if !NSApp. isActive, NSApp . windows. allSatisfy ( { !$0. isVisible } ) {
8989 log. info ( " Automatic updates enabled, installing update... " )
9090 Task {
91- try await installUpdate ( )
91+ try await downloadAndInstallUpdate ( )
92+ await relaunchAfterUpdate ( )
9293 }
9394 }
9495
@@ -173,7 +174,7 @@ final class Updater: ObservableObject {
173174 }
174175
175176 // Pulls the latest release information from GitHub and updates the app state accordingly.
176- func fetchLatestInfo( force : Bool = false ) async {
177+ func fetchLatestInfo( bypassUpdatesEnabled : Bool = false ) async {
177178 // Don't run update checks while actively downloading
178179 if downloader. isDownloading == true {
179180 return
@@ -194,8 +195,9 @@ final class Updater: ObservableObject {
194195 }
195196
196197 // Early return if updates are disabled and not forcing
197- guard updatesEnabled || force else {
198+ guard updatesEnabled || bypassUpdatesEnabled else {
198199 updateState = . unavailable
200+ log. warn ( " Updates are disabled. Not fetching latest info. " )
199201 return
200202 }
201203
@@ -210,7 +212,6 @@ final class Updater: ObservableObject {
210212 let currentBuild = Bundle . main. appBuild ?? 0
211213
212214 if let manifest = try await updateChecker. checkForUpdate (
213- bundleId: Bundle . main. bundleIdentifier ?? " com.MrKai77.Loop " ,
214215 currentVersion: currentVersion,
215216 currentBuild: currentBuild,
216217 channel: channel
@@ -257,7 +258,7 @@ final class Updater: ObservableObject {
257258 }
258259
259260 // Downloads the update from GitHub and installs it
260- func installUpdate ( ) async throws {
261+ func downloadAndInstallUpdate ( ) async throws {
261262 guard let manifest = updateManifest else {
262263 progressBar = 0
263264 return
@@ -293,9 +294,12 @@ final class Updater: ObservableObject {
293294 }
294295 }
295296
296- func relaunchAfterUpdate( ) {
297- Task {
298- await installer. restartApplication ( )
297+ func relaunchAfterUpdate( ) async {
298+ guard installState == . readyToRestart else {
299+ log. error ( " Cannot restart as the install state is \( installState) " )
300+ return
299301 }
302+
303+ await installer. restartApplication ( )
300304 }
301305}
0 commit comments