From bc032aa0a6472a3ae0c77bfd4a5085ab96638ff9 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Tue, 21 Feb 2017 12:58:56 +0900
Subject: [PATCH] Catch http errors in full update process (could happen during
 downloads too).

---
 osu.Desktop/Overlays/VersionManager.cs | 50 +++++++++++++-------------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs
index f33cd6eac2..388020dd27 100644
--- a/osu.Desktop/Overlays/VersionManager.cs
+++ b/osu.Desktop/Overlays/VersionManager.cs
@@ -119,33 +119,35 @@ namespace osu.Desktop.Overlays
             try
             {
                 updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
-            }
-            catch(HttpRequestException)
-            {
-                //check again every 30 minutes.
-                Scheduler.AddDelayed(updateChecker, 60000 * 30);
-                return;
-            }
-
-            if (!updateManager.IsInstalledApp)
-                return;
-
-            var info = await updateManager.CheckForUpdate();
-            if (info.ReleasesToApply.Count > 0)
-            {
-                ProgressNotification n = new UpdateProgressNotification
+                var info = await updateManager.CheckForUpdate();
+                if (info.ReleasesToApply.Count > 0)
                 {
-                    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);
+                    ProgressNotification n = new UpdateProgressNotification
+                    {
+                        Text = @"Downloading update..."
+                    };
+                    Schedule(() =>
+                    {
+                        notification.Post(n);
+                        n.State = ProgressNotificationState.Active;
+                    });
+                    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));
+                    Schedule(() => n.State = ProgressNotificationState.Completed);
+                }
+                else
+                {
+                    //check again every 30 minutes.
+                    Scheduler.AddDelayed(updateChecker, 60000 * 30);
+                }
             }
-            else
+            catch (HttpRequestException)
             {
                 //check again every 30 minutes.
                 Scheduler.AddDelayed(updateChecker, 60000 * 30);