private async void updateChecker() { updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); if (!updateManager.IsInstalledApp) { return; } var info = await updateManager.CheckForUpdate(); if (info.ReleasesToApply.Count > 0) { ProgressNotification n = new UpdateProgressNotification { Text = @"Downloading update..." }; Schedule(() => notification.Post(n)); Schedule(() => n.State = ProgressNotificationState.Active); await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); Schedule(() => n.Text = @"Installing update..."); await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); Schedule(() => n.State = ProgressNotificationState.Completed); } else { //check again every 30 minutes. Scheduler.AddDelayed(updateChecker, 60000 * 30); } }
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { //should we schedule a retry on completion of this check? bool scheduleRetry = true; try { if (updateManager == null) { updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); } var info = await updateManager.CheckForUpdate(!useDeltaPatching); if (info.ReleasesToApply.Count == 0) { //no updates available. bail and retry later. return; } if (notification == null) { notification = new UpdateProgressNotification { State = ProgressNotificationState.Active }; Schedule(() => notificationOverlay.Post(notification)); } Schedule(() => { notification.Progress = 0; notification.Text = @"Downloading update..."; }); try { await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => notification.Progress = p / 100f)); Schedule(() => { notification.Progress = 0; notification.Text = @"Installing update..."; }); await updateManager.ApplyReleases(info, p => Schedule(() => notification.Progress = p / 100f)); Schedule(() => notification.State = ProgressNotificationState.Completed); } catch (Exception e) { if (useDeltaPatching) { Logger.Error(e, @"delta patching failed!"); //could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) //try again without deltas. checkForUpdateAsync(false, notification); scheduleRetry = false; } else { Logger.Error(e, @"update failed!"); } } } catch (Exception) { // we'll ignore this and retry later. can be triggered by no internet connection or thread abortion. } finally { if (scheduleRetry) { //check again in 30 minutes. Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30); if (notification != null) { notification.State = ProgressNotificationState.Cancelled; } } } }
private async Task <bool> checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { // should we schedule a retry on completion of this check? bool scheduleRecheck = true; try { updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true).ConfigureAwait(false); var info = await updateManager.CheckForUpdate(!useDeltaPatching).ConfigureAwait(false); if (info.ReleasesToApply.Count == 0) { if (updatePending) { // the user may have dismissed the completion notice, so show it again. notificationOverlay.Post(new UpdateCompleteNotification(this)); return(true); } // no updates available. bail and retry later. return(false); } if (notification == null) { notification = new UpdateProgressNotification(this) { State = ProgressNotificationState.Active }; Schedule(() => notificationOverlay.Post(notification)); } notification.Progress = 0; notification.Text = @"Downloading update..."; try { await updateManager.DownloadReleases(info.ReleasesToApply, p => notification.Progress = p / 100f).ConfigureAwait(false); notification.Progress = 0; notification.Text = @"Installing update..."; await updateManager.ApplyReleases(info, p => notification.Progress = p / 100f).ConfigureAwait(false); notification.State = ProgressNotificationState.Completed; updatePending = true; } catch (Exception e) { if (useDeltaPatching) { logger.Add(@"delta patching failed; will attempt full download!"); // could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) // try again without deltas. await checkForUpdateAsync(false, notification).ConfigureAwait(false); scheduleRecheck = false; } else { notification.State = ProgressNotificationState.Cancelled; Logger.Error(e, @"update failed!"); } } } catch (Exception) { // we'll ignore this and retry later. can be triggered by no internet connection or thread abortion. } finally { if (scheduleRecheck) { // check again in 30 minutes. Scheduler.AddDelayed(async() => await checkForUpdateAsync().ConfigureAwait(false), 60000 * 30); } } return(true); }
private async Task <bool> checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { // Use translation update repository string updateRepository = "https://github.com/appleneko2001/osu"; // should we schedule a retry on completion of this check? bool scheduleRecheck = true; try { Logger.Log($"Checking updates on repository: {updateRepository}"); cancellableDownloader ??= new CancellableDownloader(); updateManager ??= await UpdateManager.GitHubUpdateManager(updateRepository, @"osulazer-zh-tw", null, cancellableDownloader, true); var info = await updateManager.CheckForUpdate(!useDeltaPatching); if (info.ReleasesToApply.Count == 0) { if (updatePending) { // the user may have dismissed the completion notice, so show it again. notificationOverlay.Post(new UpdateCompleteNotification(this)); return(true); } // no updates available. bail and retry later. return(false); } if (notification == null) { notification = new UpdateProgressNotification(this) { State = ProgressNotificationState.Active }; Schedule(() => notificationOverlay.Post(notification)); } notification.Progress = 0; notification.Text = @"下載更新中..."; try { var cancellation = notification.CancellationToken; cancellableDownloader.SetCancellationToken(cancellation); await updateManager.DownloadReleases(info.ReleasesToApply, p => notification.Progress = p / 100f); cancellation.ThrowIfCancellationRequested(); notification.Progress = 0; notification.Text = @"正在安裝..."; await updateManager.ApplyReleases(info, p => notification.Progress = p / 100f); notification.State = ProgressNotificationState.Completed; updatePending = true; } catch (OperationCanceledException) { notification.Text = "更新已取消."; notification.State = ProgressNotificationState.Cancelled; Logger.Log($"Update cancelled by user.", LoggingTarget.Runtime, Framework.Logging.LogLevel.Verbose); } catch (Exception e) { if (useDeltaPatching) { logger.Add(@"delta patching failed; will attempt full download!"); // could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) // try again without deltas. await checkForUpdateAsync(false, notification); scheduleRecheck = false; } else { notification.State = ProgressNotificationState.Cancelled; Logger.Error(e, @"update failed!"); } } } catch (Exception) { // we'll ignore this and retry later. can be triggered by no internet connection or thread abortion. } finally { if (scheduleRecheck) { // check again in 30 minutes. Scheduler.AddDelayed(async() => await checkForUpdateAsync(), 60000 * 30); } } return(true); }