1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Move storageconfig set and saving to migrate method

This commit is contained in:
Shivam 2020-06-28 15:27:50 +02:00
parent 9639ebdd97
commit 0cddb85f1b
2 changed files with 7 additions and 6 deletions

View File

@ -80,7 +80,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
// Recreate the old setup that uses "tournament" as the base path. // Recreate the old setup that uses "tournament" as the base path.
string oldPath = Path.Combine(osuRoot, "tournament"); string oldPath = Path.Combine(osuRoot, "tournament");
string videosPath = Path.Combine(oldPath, "videos"); string videosPath = Path.Combine(oldPath, "videos");
string modsPath = Path.Combine(oldPath, "mods"); string modsPath = Path.Combine(oldPath, "mods");
string flagsPath = Path.Combine(oldPath, "flags"); string flagsPath = Path.Combine(oldPath, "flags");

View File

@ -11,16 +11,17 @@ namespace osu.Game.Tournament.IO
{ {
public class TournamentStorage : MigratableStorage public class TournamentStorage : MigratableStorage
{ {
private readonly Storage storage;
public TournamentVideoResourceStore VideoStore { get; }
private const string default_tournament = "default"; private const string default_tournament = "default";
private readonly Storage storage;
private readonly TournamentStorageManager storageConfig;
public TournamentVideoResourceStore VideoStore { get; }
public TournamentStorage(Storage storage) public TournamentStorage(Storage storage)
: base(storage.GetStorageForDirectory("tournaments"), string.Empty) : base(storage.GetStorageForDirectory("tournaments"), string.Empty)
{ {
this.storage = storage; this.storage = storage;
TournamentStorageManager storageConfig = new TournamentStorageManager(storage); storageConfig = new TournamentStorageManager(storage);
if (storage.Exists("tournament.ini")) if (storage.Exists("tournament.ini"))
{ {
@ -29,8 +30,6 @@ namespace osu.Game.Tournament.IO
else else
{ {
Migrate(GetFullPath(default_tournament)); Migrate(GetFullPath(default_tournament));
storageConfig.Set(StorageConfig.CurrentTournament, default_tournament);
storageConfig.Save();
ChangeTargetStorage(UnderlyingStorage.GetStorageForDirectory(default_tournament)); ChangeTargetStorage(UnderlyingStorage.GetStorageForDirectory(default_tournament));
} }
@ -54,6 +53,8 @@ namespace osu.Game.Tournament.IO
moveFileIfExists("drawings.txt", destination); moveFileIfExists("drawings.txt", destination);
moveFileIfExists("drawings_results.txt", destination); moveFileIfExists("drawings_results.txt", destination);
moveFileIfExists("drawings.ini", destination); moveFileIfExists("drawings.ini", destination);
storageConfig.Set(StorageConfig.CurrentTournament, default_tournament);
storageConfig.Save();
} }
private void moveFileIfExists(string file, DirectoryInfo destination) private void moveFileIfExists(string file, DirectoryInfo destination)