Merge pull request #12290 from MiraiSubject/ipc-incorrect-read

This commit is contained in:
Bartłomiej Dach
2021-04-04 15:39:02 +02:00
committed by GitHub
2 changed files with 8 additions and 8 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.IO;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osu.Game.Users; using osu.Game.Users;
@ -28,7 +29,7 @@ namespace osu.Game.Tournament.Tests
protected MatchIPCInfo IPCInfo { get; private set; } = new MatchIPCInfo(); protected MatchIPCInfo IPCInfo { get; private set; } = new MatchIPCInfo();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(Storage storage) private void load(TournamentStorage storage)
{ {
Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First(); Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();

View File

@ -27,17 +27,16 @@ namespace osu.Game.Tournament.Models
private const string config_path = "stable.json"; private const string config_path = "stable.json";
private readonly Storage storage; private readonly Storage configStorage;
public StableInfo(Storage storage) public StableInfo(TournamentStorage storage)
{ {
TournamentStorage tStorage = (TournamentStorage)storage; configStorage = storage.AllTournaments;
this.storage = tStorage.AllTournaments;
if (!storage.Exists(config_path)) if (!configStorage.Exists(config_path))
return; return;
using (Stream stream = storage.GetStream(config_path, FileAccess.Read, FileMode.Open)) using (Stream stream = configStorage.GetStream(config_path, FileAccess.Read, FileMode.Open))
using (var sr = new StreamReader(stream)) using (var sr = new StreamReader(stream))
{ {
JsonConvert.PopulateObject(sr.ReadToEnd(), this); JsonConvert.PopulateObject(sr.ReadToEnd(), this);
@ -46,7 +45,7 @@ namespace osu.Game.Tournament.Models
public void SaveChanges() public void SaveChanges()
{ {
using (var stream = storage.GetStream(config_path, FileAccess.Write, FileMode.Create)) using (var stream = configStorage.GetStream(config_path, FileAccess.Write, FileMode.Create))
using (var sw = new StreamWriter(stream)) using (var sw = new StreamWriter(stream))
{ {
sw.Write(JsonConvert.SerializeObject(this, sw.Write(JsonConvert.SerializeObject(this,