mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Add resiliency to update process when delta patching fails.
This commit is contained in:
parent
cbd061d573
commit
461a22bccb
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -23,7 +24,7 @@ namespace osu.Desktop.Overlays
|
|||||||
public class VersionManager : OverlayContainer
|
public class VersionManager : OverlayContainer
|
||||||
{
|
{
|
||||||
private UpdateManager updateManager;
|
private UpdateManager updateManager;
|
||||||
private NotificationManager notification;
|
private NotificationManager notificationManager;
|
||||||
|
|
||||||
AssemblyName assembly = Assembly.GetEntryAssembly().GetName();
|
AssemblyName assembly = Assembly.GetEntryAssembly().GetName();
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ namespace osu.Desktop.Overlays
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(NotificationManager notification, OsuColour colours, TextureStore textures)
|
private void load(NotificationManager notification, OsuColour colours, TextureStore textures)
|
||||||
{
|
{
|
||||||
this.notification = notification;
|
this.notificationManager = notification;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Anchor = Anchor.BottomCentre;
|
Anchor = Anchor.BottomCentre;
|
||||||
@ -115,43 +116,59 @@ namespace osu.Desktop.Overlays
|
|||||||
updateManager?.Dispose();
|
updateManager?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void updateChecker()
|
private async void updateChecker(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
|
if (updateManager == null) updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
|
||||||
var info = await updateManager.CheckForUpdate();
|
|
||||||
|
var info = await updateManager.CheckForUpdate(!useDeltaPatching);
|
||||||
if (info.ReleasesToApply.Count > 0)
|
if (info.ReleasesToApply.Count > 0)
|
||||||
{
|
{
|
||||||
ProgressNotification n = new UpdateProgressNotification
|
if (notification == null)
|
||||||
{
|
{
|
||||||
Text = @"Downloading update..."
|
notification = new UpdateProgressNotification { State = ProgressNotificationState.Active };
|
||||||
};
|
Schedule(() => notificationManager.Post(notification));
|
||||||
|
}
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
notification.Post(n);
|
notification.Progress = 0;
|
||||||
n.State = ProgressNotificationState.Active;
|
notification.Text = @"Downloading update...";
|
||||||
});
|
|
||||||
await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => n.Progress = p / 100f));
|
|
||||||
Schedule(() =>
|
|
||||||
{
|
|
||||||
n.Progress = 0;
|
|
||||||
n.Text = @"Installing update...";
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await updateManager.ApplyReleases(info, p => Schedule(() => n.Progress = p / 100f));
|
await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => notification.Progress = p / 100f));
|
||||||
Schedule(() => n.State = ProgressNotificationState.Completed);
|
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
notification.Progress = 0;
|
||||||
|
notification.Text = @"Installing update...";
|
||||||
|
});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await updateManager.ApplyReleases(info, p => Schedule(() => notification.Progress = p / 100f));
|
||||||
|
}
|
||||||
|
catch (Win32Exception)
|
||||||
|
{
|
||||||
|
//could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
|
||||||
|
//try again without deltas.
|
||||||
|
updateChecker(false, notification);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schedule(() => notification.State = ProgressNotificationState.Completed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//check again every 30 minutes.
|
//check again every 30 minutes.
|
||||||
Scheduler.AddDelayed(updateChecker, 60000 * 30);
|
Scheduler.AddDelayed(() => updateChecker(), 60000 * 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (HttpRequestException)
|
catch (HttpRequestException)
|
||||||
{
|
{
|
||||||
//check again every 30 minutes.
|
//check again every 30 minutes.
|
||||||
Scheduler.AddDelayed(updateChecker, 60000 * 30);
|
Scheduler.AddDelayed(() => updateChecker(), 60000 * 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user