Fix beatmaps being queued for reprocessing every startup when logged out

This commit is contained in:
Dean Herbert 2023-07-25 03:15:17 +09:00
parent 69ba7afda5
commit bc671f8ac6

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets;
@ -49,6 +50,9 @@ namespace osu.Game
[Resolved]
private INotificationOverlay? notificationOverlay { get; set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
protected virtual int TimeToSleepDuringGameplay => 30000;
protected override void LoadComplete()
@ -117,12 +121,29 @@ namespace osu.Game
Logger.Log("Querying for beatmap sets to reprocess...");
realmAccess.Run(r =>
{
// BeatmapProcessor is responsible for both online and local processing.
// In the case a user isn't logged in, it won't update LastOnlineUpdate and therefore re-queue,
// causing overhead from the non-online processing to redundantly run every startup.
//
// We may eventually consider making the Process call more specific (or avoid this in any number
// of other possible ways), but for now avoid queueing if the user isn't logged in at startup.
if (api.IsLoggedIn)
{
foreach (var b in r.All<BeatmapInfo>().Where(b => b.StarRating < 0 || (b.OnlineID > 0 && b.LastOnlineUpdate == null)))
{
Debug.Assert(b.BeatmapSet != null);
beatmapSetIds.Add(b.BeatmapSet.ID);
}
}
else
{
foreach (var b in r.All<BeatmapInfo>().Where(b => b.StarRating < 0))
{
Debug.Assert(b.BeatmapSet != null);
beatmapSetIds.Add(b.BeatmapSet.ID);
}
}
});
Logger.Log($"Found {beatmapSetIds.Count} beatmap sets which require reprocessing.");