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