Fix tournament bracket parsing regression

Closes #24136.
Regressed in #24037.
This commit is contained in:
Dean Herbert 2023-07-06 17:17:16 +09:00
parent 65384d6125
commit b40532dde1
1 changed files with 8 additions and 9 deletions

View File

@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
@ -94,7 +93,7 @@ protected override void LoadComplete()
Task.Run(readBracket);
}
private void readBracket()
private async Task readBracket()
{
try
{
@ -102,7 +101,7 @@ private void readBracket()
{
using (Stream stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Read, FileMode.Open))
using (var sr = new StreamReader(stream))
ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd(), new JsonPointConverter());
ladder = JsonConvert.DeserializeObject<LadderInfo>(await sr.ReadToEndAsync().ConfigureAwait(false), new JsonPointConverter());
}
ladder ??= new LadderInfo();
@ -166,8 +165,8 @@ private void readBracket()
}
addedInfo |= addPlayers();
addedInfo |= addRoundBeatmaps();
addedInfo |= addSeedingBeatmaps();
addedInfo |= await addRoundBeatmaps().ConfigureAwait(false);
addedInfo |= await addSeedingBeatmaps().ConfigureAwait(false);
if (addedInfo)
saveChanges();
@ -233,7 +232,7 @@ private bool addPlayers()
/// <summary>
/// Add missing beatmap info based on beatmap IDs
/// </summary>
private bool addRoundBeatmaps()
private async Task<bool> addRoundBeatmaps()
{
var beatmapsRequiringPopulation = ladder.Rounds
.SelectMany(r => r.Beatmaps)
@ -246,7 +245,7 @@ private bool addRoundBeatmaps()
{
var b = beatmapsRequiringPopulation[i];
b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap());
b.Beatmap = new TournamentBeatmap(await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false) ?? new APIBeatmap());
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}
@ -257,7 +256,7 @@ private bool addRoundBeatmaps()
/// <summary>
/// Add missing beatmap info based on beatmap IDs
/// </summary>
private bool addSeedingBeatmaps()
private async Task<bool> addSeedingBeatmaps()
{
var beatmapsRequiringPopulation = ladder.Teams
.SelectMany(r => r.SeedingResults)
@ -271,7 +270,7 @@ private bool addSeedingBeatmaps()
{
var b = beatmapsRequiringPopulation[i];
b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap());
b.Beatmap = new TournamentBeatmap(await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false) ?? new APIBeatmap());
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}