mirror of
https://github.com/ppy/osu.git
synced 2026-05-24 23:21:19 +08:00
Fix update manager throwing unhandled visible to users
See https://discord.com/channels/188630481301012481/1097318920991559880/1395623942437474405.
This commit is contained in:
@@ -53,33 +53,44 @@ namespace osu.Desktop.Updater
|
||||
return false;
|
||||
}
|
||||
|
||||
IUpdateSource updateSource = new GithubSource(@"https://github.com/ppy/osu", null, ReleaseStream.Value == Game.Configuration.ReleaseStream.Tachyon);
|
||||
Velopack.UpdateManager updateManager = new Velopack.UpdateManager(updateSource, new UpdateOptions
|
||||
try
|
||||
{
|
||||
AllowVersionDowngrade = true
|
||||
});
|
||||
IUpdateSource updateSource = new GithubSource(@"https://github.com/ppy/osu", null, ReleaseStream.Value == Game.Configuration.ReleaseStream.Tachyon);
|
||||
Velopack.UpdateManager updateManager = new Velopack.UpdateManager(updateSource, new UpdateOptions
|
||||
{
|
||||
AllowVersionDowngrade = true
|
||||
});
|
||||
|
||||
UpdateInfo? update = await updateManager.CheckForUpdatesAsync().ConfigureAwait(false);
|
||||
UpdateInfo? update = await updateManager.CheckForUpdatesAsync().ConfigureAwait(false);
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
log("Update check cancelled");
|
||||
scheduleNextUpdateCheck();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (update == null)
|
||||
{
|
||||
// No update is available.
|
||||
log("No update found");
|
||||
scheduleNextUpdateCheck();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Download update in the background while notifying awaiters of the update being available.
|
||||
log($"New update available: {update.TargetFullRelease.Version}");
|
||||
downloadUpdate(updateManager, update, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log("Update check cancelled");
|
||||
log($"Update check failed with error ({e.Message})");
|
||||
|
||||
// we shouldn't crash on a web failure. or any failure for the matter.
|
||||
scheduleNextUpdateCheck();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (update == null)
|
||||
{
|
||||
// No update is available.
|
||||
log("No update found");
|
||||
scheduleNextUpdateCheck();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Download update in the background while notifying awaiters of the update being available.
|
||||
log($"New update available: {update.TargetFullRelease.Version}");
|
||||
downloadUpdate(updateManager, update, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void downloadUpdate(Velopack.UpdateManager updateManager, UpdateInfo update, CancellationToken cancellationToken) => Task.Run(async () =>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,6 +15,7 @@ using osu.Framework.Logging;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Utils;
|
||||
@@ -93,7 +95,7 @@ namespace osu.Game.Updater
|
||||
/// </summary>
|
||||
public void CheckForUpdate()
|
||||
{
|
||||
_ = CheckForUpdateAsync();
|
||||
CheckForUpdateAsync().FireAndForget();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,7 +113,15 @@ namespace osu.Game.Updater
|
||||
using (var lastCts = Interlocked.Exchange(ref updateCancellationSource, cts))
|
||||
await lastCts.CancelAsync().ConfigureAwait(false);
|
||||
|
||||
return await PerformUpdateCheck(cts.Token).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
return await PerformUpdateCheck(cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"{nameof(PerformUpdateCheck)} failed ({e.Message})");
|
||||
return false;
|
||||
}
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user