From df0966abb2475a53fed24acec5429c44dfb29bb8 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Thu, 26 Sep 2024 01:11:23 +0900
Subject: [PATCH] Update velopack and switch to using async version of
 `WaitExitThenApplyUpdates`

---
 osu.Desktop/Updater/VelopackUpdateManager.cs | 15 ++++++++-------
 osu.Desktop/osu.Desktop.csproj               |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/osu.Desktop/Updater/VelopackUpdateManager.cs b/osu.Desktop/Updater/VelopackUpdateManager.cs
index ae58a8793c..7a79284533 100644
--- a/osu.Desktop/Updater/VelopackUpdateManager.cs
+++ b/osu.Desktop/Updater/VelopackUpdateManager.cs
@@ -66,7 +66,7 @@ namespace osu.Desktop.Updater
                     {
                         Activated = () =>
                         {
-                            restartToApplyUpdate();
+                            Task.Run(restartToApplyUpdate);
                             return true;
                         }
                     });
@@ -88,7 +88,11 @@ namespace osu.Desktop.Updater
                 {
                     notification = new UpdateProgressNotification
                     {
-                        CompletionClickAction = restartToApplyUpdate,
+                        CompletionClickAction = () =>
+                        {
+                            Task.Run(restartToApplyUpdate);
+                            return true;
+                        },
                     };
 
                     Schedule(() => notificationOverlay.Post(notification));
@@ -127,13 +131,10 @@ namespace osu.Desktop.Updater
             return true;
         }
 
-        private bool restartToApplyUpdate()
+        private async Task restartToApplyUpdate()
         {
-            // TODO: Migrate this to async flow whenever available (see https://github.com/ppy/osu/pull/28743#discussion_r1740505665).
-            // Currently there's an internal Thread.Sleep(300) which will cause a stutter when the user clicks to restart.
-            updateManager.WaitExitThenApplyUpdates(pendingUpdate?.TargetFullRelease);
+            await updateManager.WaitExitThenApplyUpdatesAsync(pendingUpdate?.TargetFullRelease).ConfigureAwait(false);
             Schedule(() => game.AttemptExit());
-            return true;
         }
     }
 }
diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj
index bf5f26b352..3df8c16f08 100644
--- a/osu.Desktop/osu.Desktop.csproj
+++ b/osu.Desktop/osu.Desktop.csproj
@@ -26,7 +26,7 @@
   <ItemGroup Label="Package References">
     <PackageReference Include="System.IO.Packaging" Version="8.0.0" />
     <PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
-    <PackageReference Include="Velopack" Version="0.0.598-g933b2ab" />
+    <PackageReference Include="Velopack" Version="0.0.626" />
   </ItemGroup>
   <ItemGroup Label="Resources">
     <EmbeddedResource Include="lazer.ico" />