Implement migrations for the drawings config file

This commit is contained in:
Shivam 2020-06-11 18:21:56 +02:00
parent 32d86d6fab
commit 592e3bf4c9
2 changed files with 14 additions and 2 deletions

View File

@ -17,6 +17,7 @@ public class TournamentStorage : WrappedStorage
internal readonly TournamentVideoResourceStore VideoStore;
internal readonly Storage ConfigurationStorage;
private const string default_tournament = "default";
private const string config_directory = "config";
public TournamentStorage(GameHost host)
: base(host.Storage.GetStorageForDirectory("tournaments"), string.Empty)
@ -39,7 +40,7 @@ public TournamentStorage(GameHost host)
ChangeTargetStorage(UnderlyingStorage.GetStorageForDirectory(default_tournament));
}
ConfigurationStorage = UnderlyingStorage.GetStorageForDirectory("config");
ConfigurationStorage = UnderlyingStorage.GetStorageForDirectory(config_directory);
VideoStore = new TournamentVideoResourceStore(this);
Logger.Log("Using tournament storage: " + GetFullPath(string.Empty));
@ -49,9 +50,13 @@ internal void Migrate()
{
var source = new DirectoryInfo(host.Storage.GetFullPath("tournament"));
var destination = new DirectoryInfo(GetFullPath(default_tournament));
var cfgDestination = new DirectoryInfo(GetFullPath(default_tournament + Path.DirectorySeparatorChar + config_directory));
if (!destination.Exists)
destination.Create();
if (!cfgDestination.Exists)
destination.CreateSubdirectory(config_directory);
if (host.Storage.Exists("bracket.json"))
{
@ -67,6 +72,13 @@ internal void Migrate()
moveFile(drawingsFile, destination);
}
if (host.Storage.Exists("drawings.ini"))
{
Logger.Log("Migrating drawing configuration to default tournament storage.");
var drawingsConfigFile = new System.IO.FileInfo(host.Storage.GetFullPath("drawings.ini"));
moveFile(drawingsConfigFile, cfgDestination);
}
if (host.Storage.Exists("drawings_results.txt"))
{
Logger.Log("Migrating drawings results to default tournament storage.");

View File

@ -55,7 +55,7 @@ private void load(TextureStore textures, TournamentStorage storage)
return;
}
drawingsConfig = new DrawingsConfigManager(storage);
drawingsConfig = new DrawingsConfigManager(storage.ConfigurationStorage);
InternalChildren = new Drawable[]
{