1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:43:10 +08:00

Save last processed id to config for now

This commit is contained in:
Dean Herbert 2022-07-05 21:42:35 +09:00
parent 59d0bac728
commit bdd1bf4da0
5 changed files with 16 additions and 10 deletions

View File

@ -167,6 +167,8 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.DiscordRichPresence, DiscordRichPresenceMode.Full); SetDefault(OsuSetting.DiscordRichPresence, DiscordRichPresenceMode.Full);
SetDefault(OsuSetting.EditorWaveformOpacity, 0.25f); SetDefault(OsuSetting.EditorWaveformOpacity, 0.25f);
SetDefault(OsuSetting.LastProcessedMetadataId, -1);
} }
public IDictionary<OsuSetting, string> GetLoggableState() => public IDictionary<OsuSetting, string> GetLoggableState() =>
@ -363,5 +365,6 @@ namespace osu.Game.Configuration
DiscordRichPresence, DiscordRichPresence,
AutomaticallyDownloadWhenSpectating, AutomaticallyDownloadWhenSpectating,
ShowOnlineExplicitContent, ShowOnlineExplicitContent,
LastProcessedMetadataId
} }
} }

View File

@ -17,9 +17,9 @@ namespace osu.Game.Online.Metadata
public int[] BeatmapSetIDs { get; set; } public int[] BeatmapSetIDs { get; set; }
[Key(1)] [Key(1)]
public uint LastProcessedQueueID { get; set; } public int LastProcessedQueueID { get; set; }
public BeatmapUpdates(int[] beatmapSetIDs, uint lastProcessedQueueID) public BeatmapUpdates(int[] beatmapSetIDs, int lastProcessedQueueID)
{ {
BeatmapSetIDs = beatmapSetIDs; BeatmapSetIDs = beatmapSetIDs;
LastProcessedQueueID = lastProcessedQueueID; LastProcessedQueueID = lastProcessedQueueID;

View File

@ -16,6 +16,6 @@ namespace osu.Game.Online.Metadata
/// </summary> /// </summary>
/// <param name="queueId">The last processed queue ID.</param> /// <param name="queueId">The last processed queue ID.</param>
/// <returns></returns> /// <returns></returns>
Task<BeatmapUpdates> GetChangesSince(uint queueId); Task<BeatmapUpdates> GetChangesSince(int queueId);
} }
} }

View File

@ -10,6 +10,6 @@ namespace osu.Game.Online.Metadata
{ {
public abstract Task BeatmapSetsUpdated(BeatmapUpdates updates); public abstract Task BeatmapSetsUpdated(BeatmapUpdates updates);
public abstract Task<BeatmapUpdates> GetChangesSince(uint queueId); public abstract Task<BeatmapUpdates> GetChangesSince(int queueId);
} }
} }

View File

@ -8,6 +8,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Online.API; using osu.Game.Online.API;
namespace osu.Game.Online.Metadata namespace osu.Game.Online.Metadata
@ -19,7 +20,7 @@ namespace osu.Game.Online.Metadata
private IHubClientConnector? connector; private IHubClientConnector? connector;
private uint? lastQueueId; private Bindable<int> lastQueueId = null!;
private HubConnection? connection => connector?.CurrentConnection; private HubConnection? connection => connector?.CurrentConnection;
@ -30,7 +31,7 @@ namespace osu.Game.Online.Metadata
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IAPIProvider api) private void load(IAPIProvider api, OsuConfigManager config)
{ {
// Importantly, we are intentionally not using MessagePack here to correctly support derived class serialization. // Importantly, we are intentionally not using MessagePack here to correctly support derived class serialization.
// More information on the limitations / reasoning can be found in osu-server-spectator's initialisation code. // More information on the limitations / reasoning can be found in osu-server-spectator's initialisation code.
@ -47,6 +48,8 @@ namespace osu.Game.Online.Metadata
connector.IsConnected.BindValueChanged(isConnectedChanged, true); connector.IsConnected.BindValueChanged(isConnectedChanged, true);
} }
lastQueueId = config.GetBindable<int>(OsuSetting.LastProcessedMetadataId);
} }
private bool catchingUp; private bool catchingUp;
@ -56,7 +59,7 @@ namespace osu.Game.Online.Metadata
if (!connected.NewValue) if (!connected.NewValue)
return; return;
if (lastQueueId != null) if (lastQueueId.Value >= 0)
{ {
catchingUp = true; catchingUp = true;
@ -69,7 +72,7 @@ namespace osu.Game.Online.Metadata
Logger.Log($"Requesting catch-up from {lastQueueId.Value}"); Logger.Log($"Requesting catch-up from {lastQueueId.Value}");
var catchUpChanges = await GetChangesSince(lastQueueId.Value); var catchUpChanges = await GetChangesSince(lastQueueId.Value);
lastQueueId = catchUpChanges.LastProcessedQueueID; lastQueueId.Value = catchUpChanges.LastProcessedQueueID;
if (catchUpChanges.BeatmapSetIDs.Length == 0) if (catchUpChanges.BeatmapSetIDs.Length == 0)
{ {
@ -94,7 +97,7 @@ namespace osu.Game.Online.Metadata
// If we're still catching up, avoid updating the last ID as it will interfere with catch-up efforts. // If we're still catching up, avoid updating the last ID as it will interfere with catch-up efforts.
if (!catchingUp) if (!catchingUp)
lastQueueId = updates.LastProcessedQueueID; lastQueueId.Value = updates.LastProcessedQueueID;
await ProcessChanges(updates.BeatmapSetIDs); await ProcessChanges(updates.BeatmapSetIDs);
} }
@ -110,7 +113,7 @@ namespace osu.Game.Online.Metadata
return Task.CompletedTask; return Task.CompletedTask;
} }
public override Task<BeatmapUpdates> GetChangesSince(uint queueId) public override Task<BeatmapUpdates> GetChangesSince(int queueId)
{ {
if (connector?.IsConnected.Value != true) if (connector?.IsConnected.Value != true)
return Task.FromCanceled<BeatmapUpdates>(default); return Task.FromCanceled<BeatmapUpdates>(default);