public void TestCustomDirectory()
        {
            using (HeadlessGameHost host = new TestRunHeadlessGameHost(nameof(TestCustomDirectory), null)) // don't use clean run as we are writing a config file.
            {
                string       osuDesktopStorage = Path.Combine(host.UserStoragePaths.First(), 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.SetValue(StorageConfig.CurrentTournament, custom_tournament);

                try
                {
                    var osu = LoadTournament(host);

                    storage = osu.Dependencies.Get <Storage>();

                    Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", custom_tournament)));
                }
                finally
                {
                    host.Exit();
                }
            }
        }
Beispiel #2
0
        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.SetValue(StorageConfig.CurrentTournament, default_tournament);
            storageConfig.Save();
        }