public override void Migrate(Storage newStorage) { // this migration only happens once on moving to the per-tournament storage system. // listed files are those known at that point in time. // this can be removed at some point in the future (6 months obsoletion would mean 2021-04-19) var source = new DirectoryInfo(storage.GetFullPath("tournament")); var destination = new DirectoryInfo(newStorage.GetFullPath(".")); if (source.Exists) { Logger.Log("Migrating tournament assets to default tournament storage."); CopyRecursive(source, destination); DeleteRecursive(source); } moveFileIfExists("bracket.json", destination); moveFileIfExists("drawings.txt", destination); moveFileIfExists("drawings_results.txt", destination); moveFileIfExists("drawings.ini", destination); ChangeTargetStorage(newStorage); storageConfig.Set(StorageConfig.CurrentTournament, default_tournament); storageConfig.Save(); }
public void TestCustomDirectory() { using (HeadlessGameHost host = new HeadlessGameHost(nameof(TestCustomDirectory))) // don't use clean run as we are writing a config file. { string osuDesktopStorage = basePath(nameof(TestCustomDirectory)); const string custom_tournament = "custom"; // need access before the game has constructed its own storage yet. Storage storage = new DesktopStorage(osuDesktopStorage, host); // manual cleaning so we can prepare a config file. storage.DeleteDirectory(string.Empty); using (var storageConfig = new TournamentStorageManager(storage)) storageConfig.Set(StorageConfig.CurrentTournament, custom_tournament); try { var osu = loadOsu(host); storage = osu.Dependencies.Get <Storage>(); Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", custom_tournament))); } finally { host.Exit(); } } }