1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Fix restart notifications appearing every 30 minutes

If a user was to manually check for updates via the button, the recheck
would have been fired. This is a recent regression.

I kinda want to reorganise this code (the button press for check for
udpates shouldn't even get close to the recheck code IMO) but for now
this seems like one we should quickly fix.

Addresses https://github.com/ppy/osu/discussions/29774.
This commit is contained in:
Dean Herbert 2024-09-08 23:07:17 +09:00
parent 4a6266efcf
commit 10e84d72e5
No known key found for this signature in database

View File

@ -45,14 +45,17 @@ namespace osu.Desktop.Updater
private async Task<bool> checkForUpdateAsync(UpdateProgressNotification? notification = null) private async Task<bool> checkForUpdateAsync(UpdateProgressNotification? notification = null)
{ {
// should we schedule a retry on completion of this check? // whether to check again in 30 minutes. generally only if there's an error or no update was found (yet).
bool scheduleRecheck = true; bool scheduleRecheck = false;
try try
{ {
// Avoid any kind of update checking while gameplay is running. // Avoid any kind of update checking while gameplay is running.
if (localUserInfo?.IsPlaying.Value == true) if (localUserInfo?.IsPlaying.Value == true)
{
scheduleRecheck = true;
return false; return false;
}
// TODO: we should probably be checking if there's a more recent update, rather than shortcutting here. // TODO: we should probably be checking if there's a more recent update, rather than shortcutting here.
// Velopack does support this scenario (see https://github.com/ppy/osu/pull/28743#discussion_r1743495975). // Velopack does support this scenario (see https://github.com/ppy/osu/pull/28743#discussion_r1743495975).
@ -67,17 +70,20 @@ namespace osu.Desktop.Updater
return true; return true;
} }
}); });
return true; return true;
} }
pendingUpdate = await updateManager.CheckForUpdatesAsync().ConfigureAwait(false); pendingUpdate = await updateManager.CheckForUpdatesAsync().ConfigureAwait(false);
// Handle no updates available. // No update is available. We'll check again later.
if (pendingUpdate == null) if (pendingUpdate == null)
{
scheduleRecheck = true;
return false; return false;
}
scheduleRecheck = false; // An update is found, let's notify the user and start downloading it.
if (notification == null) if (notification == null)
{ {
notification = new UpdateProgressNotification notification = new UpdateProgressNotification
@ -113,7 +119,6 @@ namespace osu.Desktop.Updater
{ {
if (scheduleRecheck) if (scheduleRecheck)
{ {
// check again in 30 minutes.
Scheduler.AddDelayed(() => Task.Run(async () => await checkForUpdateAsync().ConfigureAwait(false)), 60000 * 30); Scheduler.AddDelayed(() => Task.Run(async () => await checkForUpdateAsync().ConfigureAwait(false)), 60000 * 30);
} }
} }