From 836efe3f7c697448b82a1f3b053ef0dd85f3efc0 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Thu, 7 May 2020 08:07:22 +0200 Subject: [PATCH 01/25] Initial commit --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 4 +++- .../Settings/Sections/General/UpdateSettings.cs | 13 ++++++++++++- osu.Game/Updater/SimpleUpdateManager.cs | 4 +++- osu.Game/Updater/UpdateManager.cs | 6 ++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index ade8460dd7..b287dd6527 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -37,10 +37,12 @@ private void load(NotificationOverlay notification, OsuGameBase game) if (game.IsDeployedBuild) { Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); - Schedule(() => Task.Run(() => checkForUpdateAsync())); + CheckForUpdate(); } } + public override void CheckForUpdate() => Schedule(() => Task.Run(() => checkForUpdateAsync())); + private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { // should we schedule a retry on completion of this check? diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 188c9c05ef..71deeee693 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -5,15 +5,19 @@ using osu.Framework.Allocation; using osu.Framework.Platform; using osu.Game.Configuration; +using osu.Game.Updater; namespace osu.Game.Overlays.Settings.Sections.General { public class UpdateSettings : SettingsSubsection { + [Resolved(CanBeNull = true)] + private UpdateManager updateManager { get; set; } + protected override string Header => "Updates"; [BackgroundDependencyLoader] - private void load(Storage storage, OsuConfigManager config) + private void load(Storage storage, OsuConfigManager config, OsuGameBase game) { Add(new SettingsEnumDropdown { @@ -21,6 +25,13 @@ private void load(Storage storage, OsuConfigManager config) Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); + Add(new SettingsButton + { + Text = "Check for updates", + Action = () => updateManager?.CheckForUpdate(), + Enabled = { Value = game.IsDeployedBuild } + }); + if (RuntimeInfo.IsDesktop) { Add(new SettingsButton diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 1e8a96444f..41248ed796 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -30,9 +30,11 @@ private void load(OsuGameBase game) version = game.Version; if (game.IsDeployedBuild) - Schedule(() => Task.Run(checkForUpdateAsync)); + CheckForUpdate(); } + public override void CheckForUpdate() => Schedule(() => Task.Run(checkForUpdateAsync)); + private async void checkForUpdateAsync() { try diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 28a295215f..f628bde324 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Logging; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Overlays; @@ -44,6 +45,11 @@ protected override void LoadComplete() config.Set(OsuSetting.Version, version); } + public virtual void CheckForUpdate() + { + Logger.Log("CheckForUpdate was called on the base class (UpdateManager)", LoggingTarget.Information); + } + private class UpdateCompleteNotification : SimpleNotification { private readonly string version; From c025814f403dc5fcf4f07342791387986c526809 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Thu, 7 May 2020 23:04:18 +0200 Subject: [PATCH 02/25] Finalize changes --- osu.Game/OsuGame.cs | 14 +++++++++++--- .../Settings/Sections/General/UpdateSettings.cs | 7 ++----- osu.Game/Updater/SimpleUpdateManager.cs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index fdc8d94352..00b967c243 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -90,7 +90,7 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler protected BackButton BackButton; - protected SettingsPanel Settings; + protected SettingsOverlay Settings; private VolumeOverlay volume; private OsuLogo osuLogo; @@ -609,6 +609,9 @@ protected override void LoadComplete() loadComponentSingleFile(screenshotManager, Add); + // dependency on notification overlay + loadComponentSingleFile(CreateUpdateManager(), Add, true); + // overlay elements loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true); loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true); @@ -641,7 +644,6 @@ protected override void LoadComplete() chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible; Add(externalLinkOpener = new ExternalLinkOpener()); - Add(CreateUpdateManager()); // dependency on notification overlay // side overlays which cancel each other. var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications }; @@ -765,11 +767,17 @@ private void forwardLoggedErrorsToNotifications() private Task asyncLoadStream; + /// + /// Schedules loading the provided in a single file. + /// + /// The component to load. + /// The method to invoke for adding the component. + /// Whether to cache the component as type into the game dependencies before any scheduling. private T loadComponentSingleFile(T d, Action add, bool cache = false) where T : Drawable { if (cache) - dependencies.Cache(d); + dependencies.CacheAs(d); if (d is OverlayContainer overlay) overlays.Add(overlay); diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 71deeee693..233a382b54 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -11,13 +11,10 @@ namespace osu.Game.Overlays.Settings.Sections.General { public class UpdateSettings : SettingsSubsection { - [Resolved(CanBeNull = true)] - private UpdateManager updateManager { get; set; } - protected override string Header => "Updates"; [BackgroundDependencyLoader] - private void load(Storage storage, OsuConfigManager config, OsuGameBase game) + private void load(Storage storage, OsuConfigManager config, OsuGameBase game, UpdateManager updateManager) { Add(new SettingsEnumDropdown { @@ -28,7 +25,7 @@ private void load(Storage storage, OsuConfigManager config, OsuGameBase game) Add(new SettingsButton { Text = "Check for updates", - Action = () => updateManager?.CheckForUpdate(), + Action = () => updateManager.CheckForUpdate(), Enabled = { Value = game.IsDeployedBuild } }); diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 41248ed796..234fe8be8b 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -33,7 +33,7 @@ private void load(OsuGameBase game) CheckForUpdate(); } - public override void CheckForUpdate() => Schedule(() => Task.Run(checkForUpdateAsync)); + public override void CheckForUpdate() => Schedule(() => Task.Run(() => checkForUpdateAsync())); private async void checkForUpdateAsync() { From 92872496b86db2681da81cc151223e5707464940 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Thu, 7 May 2020 23:27:28 +0200 Subject: [PATCH 03/25] Convert to method groups because Inspector said so. --- osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs | 2 +- osu.Game/Updater/SimpleUpdateManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 233a382b54..5ddd12f667 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -25,7 +25,7 @@ private void load(Storage storage, OsuConfigManager config, OsuGameBase game, Up Add(new SettingsButton { Text = "Check for updates", - Action = () => updateManager.CheckForUpdate(), + Action = updateManager.CheckForUpdate, Enabled = { Value = game.IsDeployedBuild } }); diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 234fe8be8b..41248ed796 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -33,7 +33,7 @@ private void load(OsuGameBase game) CheckForUpdate(); } - public override void CheckForUpdate() => Schedule(() => Task.Run(() => checkForUpdateAsync())); + public override void CheckForUpdate() => Schedule(() => Task.Run(checkForUpdateAsync)); private async void checkForUpdateAsync() { From 72b6bb25a5c1125f038d4b079e2e57fd31fdbcd1 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 00:33:33 +0200 Subject: [PATCH 04/25] Allow nulls and hide if missing dependencies --- .../Settings/Sections/General/UpdateSettings.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 5ddd12f667..23ca752f6e 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -13,7 +13,7 @@ public class UpdateSettings : SettingsSubsection { protected override string Header => "Updates"; - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(true)] private void load(Storage storage, OsuConfigManager config, OsuGameBase game, UpdateManager updateManager) { Add(new SettingsEnumDropdown @@ -22,12 +22,15 @@ private void load(Storage storage, OsuConfigManager config, OsuGameBase game, Up Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); - Add(new SettingsButton + if (game != null && updateManager != null) { - Text = "Check for updates", - Action = updateManager.CheckForUpdate, - Enabled = { Value = game.IsDeployedBuild } - }); + Add(new SettingsButton + { + Text = "Check for updates", + Action = updateManager.CheckForUpdate, + Enabled = { Value = game.IsDeployedBuild } + }); + } if (RuntimeInfo.IsDesktop) { From 477bd7fa613c75a6b535324cf59e42bdb7dce669 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 00:35:27 +0200 Subject: [PATCH 05/25] Change to Resolved attribute --- .../Overlays/Settings/Sections/General/UpdateSettings.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 23ca752f6e..5af6a060ee 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -11,10 +11,16 @@ namespace osu.Game.Overlays.Settings.Sections.General { public class UpdateSettings : SettingsSubsection { + [Resolved(CanBeNull = true)] + private OsuGameBase game { get; set; } + + [Resolved(CanBeNull = true)] + private UpdateManager updateManager { get; set; } + protected override string Header => "Updates"; [BackgroundDependencyLoader(true)] - private void load(Storage storage, OsuConfigManager config, OsuGameBase game, UpdateManager updateManager) + private void load(Storage storage, OsuConfigManager config) { Add(new SettingsEnumDropdown { From a7792070bc01f4108515f665f5ff17dc750c25e4 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 01:08:17 +0200 Subject: [PATCH 06/25] Final changes to DI fields and values --- .../Settings/Sections/General/UpdateSettings.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 5af6a060ee..58966e8a4c 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -11,16 +11,13 @@ namespace osu.Game.Overlays.Settings.Sections.General { public class UpdateSettings : SettingsSubsection { - [Resolved(CanBeNull = true)] - private OsuGameBase game { get; set; } - [Resolved(CanBeNull = true)] private UpdateManager updateManager { get; set; } protected override string Header => "Updates"; - [BackgroundDependencyLoader(true)] - private void load(Storage storage, OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(Storage storage, OsuConfigManager config, OsuGameBase game) { Add(new SettingsEnumDropdown { @@ -28,7 +25,8 @@ private void load(Storage storage, OsuConfigManager config) Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); - if (game != null && updateManager != null) + // We shouldn't display the button for the base UpdateManager (without updating logic) + if (updateManager != null && updateManager.GetType() != typeof(UpdateManager)) { Add(new SettingsButton { From 75e65766ffcf0e3e1820407534bcd0104d469adb Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 01:09:16 +0200 Subject: [PATCH 07/25] Annotate dependency --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 00b967c243..899056e179 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -609,7 +609,7 @@ protected override void LoadComplete() loadComponentSingleFile(screenshotManager, Add); - // dependency on notification overlay + // dependency on notification overlay, dependent by settings overlay loadComponentSingleFile(CreateUpdateManager(), Add, true); // overlay elements From e6ad28a1cbb66359faa430446ae1d7b1fbc75b64 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 02:09:37 +0200 Subject: [PATCH 08/25] Use property instead of type checking --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 2 ++ osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs | 4 ++-- osu.Game/Updater/SimpleUpdateManager.cs | 2 ++ osu.Game/Updater/UpdateManager.cs | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index b287dd6527..2834f1f71d 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -22,6 +22,8 @@ namespace osu.Desktop.Updater { public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager { + public override bool CanPerformUpdate => true; + private UpdateManager updateManager; private NotificationOverlay notificationOverlay; diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 58966e8a4c..b832e8930a 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -25,8 +25,8 @@ private void load(Storage storage, OsuConfigManager config, OsuGameBase game) Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); - // We shouldn't display the button for the base UpdateManager (without updating logic) - if (updateManager != null && updateManager.GetType() != typeof(UpdateManager)) + // We should only display the button for UpdateManagers that do update the client + if (updateManager != null && updateManager.CanPerformUpdate) { Add(new SettingsButton { diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 41248ed796..5cc42090f4 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -19,6 +19,8 @@ namespace osu.Game.Updater /// public class SimpleUpdateManager : UpdateManager { + public override bool CanPerformUpdate => true; + private string version; [Resolved] diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index f628bde324..f8c8bfe967 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -17,6 +17,8 @@ namespace osu.Game.Updater /// public class UpdateManager : CompositeDrawable { + public virtual bool CanPerformUpdate => false; + [Resolved] private OsuConfigManager config { get; set; } From 7f61f27be1e3031266110c0f64a812bc2a787829 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 02:33:12 +0200 Subject: [PATCH 09/25] Use null-conditional operator when checking against UpdateManager Co-authored-by: Dean Herbert --- osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index b832e8930a..6ea9c975de 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -26,7 +26,7 @@ private void load(Storage storage, OsuConfigManager config, OsuGameBase game) }); // We should only display the button for UpdateManagers that do update the client - if (updateManager != null && updateManager.CanPerformUpdate) + if (updateManager?.CanPerformUpdate == true) { Add(new SettingsButton { From 3c24ca08d042782166b0e1a7e1ce7297062e309e Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 02:48:27 +0200 Subject: [PATCH 10/25] Check whether the build is deployed within the public check updates method --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 15 +++++++++------ osu.Game/Updater/SimpleUpdateManager.cs | 12 +++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index 2834f1f71d..a3b21b4bd9 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -26,6 +26,7 @@ public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager private UpdateManager updateManager; private NotificationOverlay notificationOverlay; + private OsuGameBase gameBase; public Task PrepareUpdateAsync() => UpdateManager.RestartAppWhenExited(); @@ -34,16 +35,18 @@ public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager [BackgroundDependencyLoader] private void load(NotificationOverlay notification, OsuGameBase game) { + gameBase = game; notificationOverlay = notification; - if (game.IsDeployedBuild) - { - Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); - CheckForUpdate(); - } + Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); + CheckForUpdate(); } - public override void CheckForUpdate() => Schedule(() => Task.Run(() => checkForUpdateAsync())); + public override void CheckForUpdate() + { + if (gameBase.IsDeployedBuild) + Schedule(() => Task.Run(() => checkForUpdateAsync())); + } private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 5cc42090f4..8513ea94b4 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -26,16 +26,22 @@ public class SimpleUpdateManager : UpdateManager [Resolved] private GameHost host { get; set; } + private OsuGameBase gameBase; + [BackgroundDependencyLoader] private void load(OsuGameBase game) { + gameBase = game; version = game.Version; - if (game.IsDeployedBuild) - CheckForUpdate(); + CheckForUpdate(); } - public override void CheckForUpdate() => Schedule(() => Task.Run(checkForUpdateAsync)); + public override void CheckForUpdate() + { + if (gameBase.IsDeployedBuild) + Schedule(() => Task.Run(checkForUpdateAsync)); + } private async void checkForUpdateAsync() { From ebd1df8c2822a76c683b1b0f01e6e7677c3a8f70 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Fri, 8 May 2020 02:50:58 +0200 Subject: [PATCH 11/25] Change property name to CanCheckForUpdate --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 2 +- .../Overlays/Settings/Sections/General/UpdateSettings.cs | 4 ++-- osu.Game/Updater/SimpleUpdateManager.cs | 2 +- osu.Game/Updater/UpdateManager.cs | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index a3b21b4bd9..5c553f18f4 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -22,7 +22,7 @@ namespace osu.Desktop.Updater { public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager { - public override bool CanPerformUpdate => true; + public override bool CanCheckForUpdate => true; private UpdateManager updateManager; private NotificationOverlay notificationOverlay; diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index b832e8930a..cadffd9d86 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -25,8 +25,8 @@ private void load(Storage storage, OsuConfigManager config, OsuGameBase game) Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); - // We should only display the button for UpdateManagers that do update the client - if (updateManager != null && updateManager.CanPerformUpdate) + // We should only display the button for UpdateManagers that do check for updates + if (updateManager != null && updateManager.CanCheckForUpdate) { Add(new SettingsButton { diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 8513ea94b4..d4e8aed5ae 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -19,7 +19,7 @@ namespace osu.Game.Updater /// public class SimpleUpdateManager : UpdateManager { - public override bool CanPerformUpdate => true; + public override bool CanCheckForUpdate => true; private string version; diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index f8c8bfe967..41bbfb76a5 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -17,7 +17,10 @@ namespace osu.Game.Updater /// public class UpdateManager : CompositeDrawable { - public virtual bool CanPerformUpdate => false; + /// + /// Whether this UpdateManager is capable of checking for updates. + /// + public virtual bool CanCheckForUpdate => false; [Resolved] private OsuConfigManager config { get; set; } From 39c36998c99509104c60f23cdce61a70e64e3c59 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Tue, 12 May 2020 06:06:31 +0200 Subject: [PATCH 12/25] Revert changes that are to be resolved in #9002 --- osu.Game/OsuGame.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 899056e179..294180cb30 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -90,7 +90,7 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler protected BackButton BackButton; - protected SettingsOverlay Settings; + protected SettingsPanel Settings; private VolumeOverlay volume; private OsuLogo osuLogo; @@ -767,17 +767,11 @@ private void forwardLoggedErrorsToNotifications() private Task asyncLoadStream; - /// - /// Schedules loading the provided in a single file. - /// - /// The component to load. - /// The method to invoke for adding the component. - /// Whether to cache the component as type into the game dependencies before any scheduling. private T loadComponentSingleFile(T d, Action add, bool cache = false) where T : Drawable { if (cache) - dependencies.CacheAs(d); + dependencies.Cache(d); if (d is OverlayContainer overlay) overlays.Add(overlay); From 101604e741c70ffa92f0b10c39191d687749316b Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Mon, 8 Jun 2020 00:39:33 +0200 Subject: [PATCH 13/25] Redesign classes and generally improve code --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 20 +++------ .../Sections/General/UpdateSettings.cs | 14 +++--- osu.Game/Updater/SimpleUpdateManager.cs | 15 +------ osu.Game/Updater/UpdateManager.cs | 43 +++++++++++++------ 4 files changed, 43 insertions(+), 49 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index 5c553f18f4..c55917fb5f 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -22,33 +22,25 @@ namespace osu.Desktop.Updater { public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager { - public override bool CanCheckForUpdate => true; - private UpdateManager updateManager; private NotificationOverlay notificationOverlay; - private OsuGameBase gameBase; public Task PrepareUpdateAsync() => UpdateManager.RestartAppWhenExited(); private static readonly Logger logger = Logger.GetLogger("updater"); [BackgroundDependencyLoader] - private void load(NotificationOverlay notification, OsuGameBase game) + private void load(NotificationOverlay notification) { - gameBase = game; notificationOverlay = notification; Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); - CheckForUpdate(); + Schedule(() => Task.Run(CheckForUpdateAsync)); } - public override void CheckForUpdate() - { - if (gameBase.IsDeployedBuild) - Schedule(() => Task.Run(() => checkForUpdateAsync())); - } + protected override async Task InternalCheckForUpdateAsync() => await checkForUpdateAsync(); - private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) + private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { // should we schedule a retry on completion of this check? bool scheduleRecheck = true; @@ -90,7 +82,7 @@ private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgr // 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); + await checkForUpdateAsync(false, notification); scheduleRecheck = false; } else @@ -109,7 +101,7 @@ private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgr if (scheduleRecheck) { // check again in 30 minutes. - Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30); + Scheduler.AddDelayed(async () => await checkForUpdateAsync(), 60000 * 30); } } } diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 62d1ef162f..4a2a50885e 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Platform; @@ -28,15 +29,12 @@ private void load(Storage storage, OsuConfigManager config, OsuGame game) }); // We should only display the button for UpdateManagers that do check for updates - if (updateManager?.CanCheckForUpdate == true) + Add(new SettingsButton { - Add(new SettingsButton - { - Text = "Check for updates", - Action = updateManager.CheckForUpdate, - Enabled = { Value = game.IsDeployedBuild } - }); - } + Text = "Check for updates", + Action = () => Schedule(() => Task.Run(updateManager.CheckForUpdateAsync)), + Enabled = { Value = updateManager.CanCheckForUpdate } + }); if (RuntimeInfo.IsDesktop) { diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index d4e8aed5ae..78d27ab754 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -19,31 +19,20 @@ namespace osu.Game.Updater /// public class SimpleUpdateManager : UpdateManager { - public override bool CanCheckForUpdate => true; - private string version; [Resolved] private GameHost host { get; set; } - private OsuGameBase gameBase; - [BackgroundDependencyLoader] private void load(OsuGameBase game) { - gameBase = game; version = game.Version; - CheckForUpdate(); + Schedule(() => Task.Run(CheckForUpdateAsync)); } - public override void CheckForUpdate() - { - if (gameBase.IsDeployedBuild) - Schedule(() => Task.Run(checkForUpdateAsync)); - } - - private async void checkForUpdateAsync() + protected override async Task InternalCheckForUpdateAsync() { try { diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 41bbfb76a5..abe21f08a4 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -1,10 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Logging; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Overlays; @@ -18,9 +18,11 @@ namespace osu.Game.Updater public class UpdateManager : CompositeDrawable { /// - /// Whether this UpdateManager is capable of checking for updates. + /// Whether this UpdateManager should be or is capable of checking for updates. /// - public virtual bool CanCheckForUpdate => false; + public bool CanCheckForUpdate => game.IsDeployedBuild; + + private string lastVersion; [Resolved] private OsuConfigManager config { get; set; } @@ -35,24 +37,37 @@ protected override void LoadComplete() { base.LoadComplete(); - var version = game.Version; - var lastVersion = config.Get(OsuSetting.Version); + Schedule(() => Task.Run(CheckForUpdateAsync)); - if (game.IsDeployedBuild && version != lastVersion) + // debug / local compilations will reset to a non-release string. + // can be useful to check when an install has transitioned between release and otherwise (see OsuConfigManager's migrations). + config.Set(OsuSetting.Version, game.Version); + } + + public async Task CheckForUpdateAsync() + { + if (!CanCheckForUpdate) + return; + + await InternalCheckForUpdateAsync(); + } + + protected virtual Task InternalCheckForUpdateAsync() + { + // Query last version only *once*, so the user can re-check for updates, in case they closed the notification or else. + lastVersion ??= config.Get(OsuSetting.Version); + + var version = game.Version; + + if (version != lastVersion) { // only show a notification if we've previously saved a version to the config file (ie. not the first run). if (!string.IsNullOrEmpty(lastVersion)) Notifications.Post(new UpdateCompleteNotification(version)); } - // debug / local compilations will reset to a non-release string. - // can be useful to check when an install has transitioned between release and otherwise (see OsuConfigManager's migrations). - config.Set(OsuSetting.Version, version); - } - - public virtual void CheckForUpdate() - { - Logger.Log("CheckForUpdate was called on the base class (UpdateManager)", LoggingTarget.Information); + // we aren't doing any async in this method, so we return a completed task instead. + return Task.CompletedTask; } private class UpdateCompleteNotification : SimpleNotification From 95f57ca88c3f17ddebe7e449d8345e9c672d98fc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 18:05:23 +0900 Subject: [PATCH 14/25] Remove duplicate calls to CheckForUpdatesAsync --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 1 - osu.Game/Updater/SimpleUpdateManager.cs | 2 -- 2 files changed, 3 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index 3bd10215c2..748969ade5 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -35,7 +35,6 @@ private void load(NotificationOverlay notification) notificationOverlay = notification; Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); - Schedule(() => Task.Run(CheckForUpdateAsync)); } protected override async Task InternalCheckForUpdateAsync() => await checkForUpdateAsync(); diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 78d27ab754..b61c88a280 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -28,8 +28,6 @@ public class SimpleUpdateManager : UpdateManager private void load(OsuGameBase game) { version = game.Version; - - Schedule(() => Task.Run(CheckForUpdateAsync)); } protected override async Task InternalCheckForUpdateAsync() From 6beb28b685205a886e98235c6c332912b612ad18 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 18:07:39 +0900 Subject: [PATCH 15/25] Rename method to be less bad --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 2 +- osu.Game/Updater/SimpleUpdateManager.cs | 2 +- osu.Game/Updater/UpdateManager.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index 748969ade5..05c8e835ac 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -37,7 +37,7 @@ private void load(NotificationOverlay notification) Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); } - protected override async Task InternalCheckForUpdateAsync() => await checkForUpdateAsync(); + protected override async Task PerformUpdateCheck() => await checkForUpdateAsync(); private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index b61c88a280..ebb9995c66 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -30,7 +30,7 @@ private void load(OsuGameBase game) version = game.Version; } - protected override async Task InternalCheckForUpdateAsync() + protected override async Task PerformUpdateCheck() { try { diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index abe21f08a4..9037187e8d 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -49,10 +49,10 @@ public async Task CheckForUpdateAsync() if (!CanCheckForUpdate) return; - await InternalCheckForUpdateAsync(); + await PerformUpdateCheck(); } - protected virtual Task InternalCheckForUpdateAsync() + protected virtual Task PerformUpdateCheck() { // Query last version only *once*, so the user can re-check for updates, in case they closed the notification or else. lastVersion ??= config.Get(OsuSetting.Version); From 3dd642a33667d53d5d78a857c1f5548e335f9882 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 18:29:21 +0900 Subject: [PATCH 16/25] Ensure only one update check can be running at a time --- osu.Game/Updater/UpdateManager.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 9037187e8d..06d6a39066 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -44,12 +44,22 @@ protected override void LoadComplete() config.Set(OsuSetting.Version, game.Version); } + private readonly object updateTaskLock = new object(); + + private Task updateCheckTask; + public async Task CheckForUpdateAsync() { if (!CanCheckForUpdate) return; - await PerformUpdateCheck(); + lock (updateTaskLock) + updateCheckTask ??= PerformUpdateCheck(); + + await updateCheckTask; + + lock (updateTaskLock) + updateCheckTask = null; } protected virtual Task PerformUpdateCheck() From 4f809767a5f9cf762244843021a6f33ac99c94af Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 18:36:36 +0900 Subject: [PATCH 17/25] Disable button while update check is in progress --- .../Settings/Sections/General/UpdateSettings.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 4a2a50885e..869e6c9c51 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -19,6 +19,8 @@ public class UpdateSettings : SettingsSubsection protected override string Header => "Updates"; + private SettingsButton checkForUpdatesButton; + [BackgroundDependencyLoader(true)] private void load(Storage storage, OsuConfigManager config, OsuGame game) { @@ -29,11 +31,14 @@ private void load(Storage storage, OsuConfigManager config, OsuGame game) }); // We should only display the button for UpdateManagers that do check for updates - Add(new SettingsButton + Add(checkForUpdatesButton = new SettingsButton { Text = "Check for updates", - Action = () => Schedule(() => Task.Run(updateManager.CheckForUpdateAsync)), - Enabled = { Value = updateManager.CanCheckForUpdate } + Action = () => + { + checkForUpdatesButton.Enabled.Value = false; + Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() => checkForUpdatesButton.Enabled.Value = true)); + } }); if (RuntimeInfo.IsDesktop) From 35f577375c53c9f1a7c2cc159c32d468a2d9ce41 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 19:20:45 +0900 Subject: [PATCH 18/25] Restore notification code --- osu.Game/Updater/UpdateManager.cs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 06d6a39066..35f9ad512f 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -39,6 +39,18 @@ protected override void LoadComplete() Schedule(() => Task.Run(CheckForUpdateAsync)); + // Query last version only *once*, so the user can re-check for updates, in case they closed the notification or else. + lastVersion ??= config.Get(OsuSetting.Version); + + var version = game.Version; + + if (game.IsDeployedBuild && version != lastVersion) + { + // only show a notification if we've previously saved a version to the config file (ie. not the first run). + if (!string.IsNullOrEmpty(lastVersion)) + Notifications.Post(new UpdateCompleteNotification(version)); + } + // debug / local compilations will reset to a non-release string. // can be useful to check when an install has transitioned between release and otherwise (see OsuConfigManager's migrations). config.Set(OsuSetting.Version, game.Version); @@ -62,23 +74,7 @@ public async Task CheckForUpdateAsync() updateCheckTask = null; } - protected virtual Task PerformUpdateCheck() - { - // Query last version only *once*, so the user can re-check for updates, in case they closed the notification or else. - lastVersion ??= config.Get(OsuSetting.Version); - - var version = game.Version; - - if (version != lastVersion) - { - // only show a notification if we've previously saved a version to the config file (ie. not the first run). - if (!string.IsNullOrEmpty(lastVersion)) - Notifications.Post(new UpdateCompleteNotification(version)); - } - - // we aren't doing any async in this method, so we return a completed task instead. - return Task.CompletedTask; - } + protected virtual Task PerformUpdateCheck() => Task.CompletedTask; private class UpdateCompleteNotification : SimpleNotification { From 89cf146d18a804cca959ff18dfceb399bbb31828 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 19:24:50 +0900 Subject: [PATCH 19/25] Fix base UpdateManager thinking it can check for updates --- osu.Game/Updater/UpdateManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 35f9ad512f..d3a05deac5 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -20,7 +20,9 @@ public class UpdateManager : CompositeDrawable /// /// Whether this UpdateManager should be or is capable of checking for updates. /// - public bool CanCheckForUpdate => game.IsDeployedBuild; + public bool CanCheckForUpdate => game.IsDeployedBuild && + // only implementations will actually check for updates. + GetType() != typeof(UpdateManager); private string lastVersion; From 446ce2590cf93c4c69072f0e384d803ded88fc16 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 19:25:54 +0900 Subject: [PATCH 20/25] Move local back in place --- osu.Game/Updater/UpdateManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index d3a05deac5..51f48264b8 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -24,8 +24,6 @@ public class UpdateManager : CompositeDrawable // only implementations will actually check for updates. GetType() != typeof(UpdateManager); - private string lastVersion; - [Resolved] private OsuConfigManager config { get; set; } @@ -42,7 +40,7 @@ protected override void LoadComplete() Schedule(() => Task.Run(CheckForUpdateAsync)); // Query last version only *once*, so the user can re-check for updates, in case they closed the notification or else. - lastVersion ??= config.Get(OsuSetting.Version); + var lastVersion = config.Get(OsuSetting.Version); var version = game.Version; From f5c3863e6d97f71b65f06de59f2754b03f71f642 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 19:26:46 +0900 Subject: [PATCH 21/25] Revert variable usage --- osu.Game/Updater/UpdateManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 51f48264b8..bcaaf8e343 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -53,7 +53,7 @@ protected override void LoadComplete() // debug / local compilations will reset to a non-release string. // can be useful to check when an install has transitioned between release and otherwise (see OsuConfigManager's migrations). - config.Set(OsuSetting.Version, game.Version); + config.Set(OsuSetting.Version, version); } private readonly object updateTaskLock = new object(); From 7ae421cc8e8a64f73a65e77e92c40c318f23b6a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jun 2020 19:32:32 +0900 Subject: [PATCH 22/25] Revert more incorrect changes --- osu.Game/Updater/UpdateManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index bcaaf8e343..5da366bde9 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -39,11 +39,10 @@ protected override void LoadComplete() Schedule(() => Task.Run(CheckForUpdateAsync)); - // Query last version only *once*, so the user can re-check for updates, in case they closed the notification or else. - var lastVersion = config.Get(OsuSetting.Version); - var version = game.Version; + var lastVersion = config.Get(OsuSetting.Version); + if (game.IsDeployedBuild && version != lastVersion) { // only show a notification if we've previously saved a version to the config file (ie. not the first run). From d2155c3da3c01e54636a5ce4876618f68acb855f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jun 2020 22:19:02 +0900 Subject: [PATCH 23/25] Fix thread safety --- osu.Game/Updater/UpdateManager.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 5da366bde9..61775a26b7 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -64,10 +64,12 @@ public async Task CheckForUpdateAsync() if (!CanCheckForUpdate) return; - lock (updateTaskLock) - updateCheckTask ??= PerformUpdateCheck(); + Task waitTask; - await updateCheckTask; + lock (updateTaskLock) + waitTask = (updateCheckTask ??= PerformUpdateCheck()); + + await waitTask; lock (updateTaskLock) updateCheckTask = null; From 53b7057ee05a3551c07ac7e0d2a00f15f13b4c29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jun 2020 22:19:11 +0900 Subject: [PATCH 24/25] Don't show update button when updates are not feasible --- .../Sections/General/UpdateSettings.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 869e6c9c51..9fca820cac 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -30,16 +30,18 @@ private void load(Storage storage, OsuConfigManager config, OsuGame game) Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); - // We should only display the button for UpdateManagers that do check for updates - Add(checkForUpdatesButton = new SettingsButton + if (updateManager.CanCheckForUpdate) { - Text = "Check for updates", - Action = () => + Add(checkForUpdatesButton = new SettingsButton { - checkForUpdatesButton.Enabled.Value = false; - Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() => checkForUpdatesButton.Enabled.Value = true)); - } - }); + Text = "Check for updates", + Action = () => + { + checkForUpdatesButton.Enabled.Value = false; + Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() => checkForUpdatesButton.Enabled.Value = true)); + } + }); + } if (RuntimeInfo.IsDesktop) { From 97067976f75a416dd8adc290aed8841ab51740ad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jun 2020 22:23:06 +0900 Subject: [PATCH 25/25] Add null check --- osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 9fca820cac..9c7d0b0be4 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -30,7 +30,7 @@ private void load(Storage storage, OsuConfigManager config, OsuGame game) Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); - if (updateManager.CanCheckForUpdate) + if (updateManager?.CanCheckForUpdate == true) { Add(checkForUpdatesButton = new SettingsButton {