private void ApplyReleasesCallback(Action <UpdateStatus, int> progressCallback, Action <Exception> errCallback, string installPath) { progressCallback(UpdateStatus.Installing, 100); Log.Info("Squirrel: Creating uninstall info..."); var createUninstallerRegistryEntryTask = _updateManager.CreateUninstallerRegistryEntry(); createUninstallerRegistryEntryTask.ContinueWith(t => CreateUninstallerRegistryEntryCallback(progressCallback, errCallback, installPath), TaskContinuationOptions.OnlyOnRanToCompletion); createUninstallerRegistryEntryTask.ContinueWith(t => HandleAsyncError(errCallback, t.Exception), TaskContinuationOptions.OnlyOnFaulted); }
public static async Task <ReleaseEntry> UpdateApp(this IUpdateManager This, Action <int> progress = null) { progress = progress ?? (_ => {}); This.Log().Info("Starting automatic update"); bool ignoreDeltaUpdates = false; retry: var updateInfo = default(UpdateInfo); try { updateInfo = await This.ErrorIfThrows(() => This.CheckForUpdate(ignoreDeltaUpdates, x => progress(x / 3)), "Failed to check for updates"); await This.ErrorIfThrows(() => This.DownloadReleases(updateInfo.ReleasesToApply, x => progress(x / 3 + 33)), "Failed to download updates"); await This.ErrorIfThrows(() => This.ApplyReleases(updateInfo, x => progress(x / 3 + 66)), "Failed to apply updates"); await This.ErrorIfThrows(() => This.CreateUninstallerRegistryEntry(), "Failed to set up uninstaller"); } catch (Exception ex) { if (ignoreDeltaUpdates == false) { ignoreDeltaUpdates = true; goto retry; } throw; } return(updateInfo.ReleasesToApply.Any() ? updateInfo.ReleasesToApply.MaxBy(x => x.Version).Last() : default(ReleaseEntry)); }