Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic setup switching for the tournament client #9256

Merged
merged 65 commits into from
Oct 19, 2020

Conversation

MiraiSubject
Copy link
Contributor

@MiraiSubject MiraiSubject commented Jun 11, 2020

From #9199, this fulfils

Create a default tournament profile and the necessary migrations for the flags, mods, videos and other assets.

This PR changes the default path for tournaments from %APPDATA%\osu\tournament to %APPDATA%\osu\tournaments\default.
Migrations for this are implemented so that this change does not break existing configurations and the necessary tests are also written for that. The migration also includes moving the bracket.json to the same directory.

Upon migration a tournament.ini gets created with the following default value:

CurrentTournament = default

Post-migration scenario

The user can now add directories in the following format:

(%APPDATA%/osu/tournaments)
tournament-name
 ┃ ┣ config
 ┃ ┃ ┗ drawings.ini
 ┃ ┣ flags
 ┃ ┣ mods
 ┃ ┣ videos
 ┃ ┣ bracket.json
 ┃ ┣ drawings.txt
 ┃ ┗ drawings_results.txt

and then change the tournament.ini to:

CurrentTournament = tournament-name

Because of this, switching the storage requires a reboot of the tournament client.

@peppy
Copy link
Member

peppy commented Jun 12, 2020

Generally if something depends on another branch/PR, you should rebase it on top of that (so it will compile and work for testing).

@MiraiSubject
Copy link
Contributor Author

Generally if something depends on another branch/PR, you should rebase it on top of that (so it will compile and work for testing).

I locally tested by merging this branch into #9247, stashed any changes I wanted to keep and then applied it to this branch. It's a very roundabout way of doing things, but it was the only way I was familiar and comfortable with.

I'll look into rebasing.

@peppy
Copy link
Member

peppy commented Jun 12, 2020

It's fine this time around, just a heads-up for future contributions.

osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs Outdated Show resolved Hide resolved
Comment on lines 17 to 18
internal virtual string[] IgnoreDirectories => Array.Empty<string>();
internal virtual string[] IgnoreFiles => Array.Empty<string>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird modifier mix. Any consumers from a different assembly that might want to override this will not be able to. I think this calls for the rarely-seen

Suggested change
internal virtual string[] IgnoreDirectories => Array.Empty<string>();
internal virtual string[] IgnoreFiles => Array.Empty<string>();
protected internal virtual string[] IgnoreDirectories => Array.Empty<string>();
protected internal virtual string[] IgnoreFiles => Array.Empty<string>();

(Or heck, just make it public, I don't think that's that much of a deal.)

Needs to be fixed up in the override too if this happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to public for now, will await further feedback about this in case protected becomes the preferred way to go.

@pull-request-size pull-request-size bot added size/XL and removed size/L labels Jul 1, 2020
@MiraiSubject
Copy link
Contributor Author

I've been looking into making Migrate more sane.

Right now I moved the original Migrate from OsuStorage to MigratableStorage (+xmldoc) so that consumers can use this as a general purpose migrator.

I've also looked into making the TournamentStorage's Migrate use MigratableStorage's but that's not possible because the destination is nested inside the source. That goes along with the structure of what's being migrated is different from what it would be in a general case.

Before:

(%APPDATA%/osu/)
... cache, files, etc.
 ┃ ┣ tournament/
 ┃ ┃ ┣  flags
 ┃ ┃ ┣  mods
 ┃ ┃ ┗  videos
 ┃ ┣  bracket.json
 ┃ ┣ drawings.txt.
 ┃ ┣ drawings_results.txt.
 ┃ ┗ drawings.ini
...  framework.ini, online.db, etc.

After:

(%APPDATA%/osu/tournaments)
default
 ┃ ┣ flags
 ┃ ┣ mods
 ┃ ┣ videos
 ┃ ┣ bracket.json
 ┃ ┣ drawings.txt
 ┃ ┣ drawings.ini
 ┃ ┗ drawings_results.txt

@bdach
Copy link
Collaborator

bdach commented Jul 1, 2020

As a heads up, this is probably going to have major merge conflicts with #9417 / #9418...

As for the issue mentioned I'd probably advise that the Migrate() method be overridable and that TournamentStorage hoist the files one level out of tournament/ as a post-migration step.

Forgot to change this while changing the param from string to Storage
@MiraiSubject
Copy link
Contributor Author

Alright thanks! I'll hold off from any more big changes until after those are merged

I made Migrate already overridable and its implementation in TournamentStorage is being completely overridden without ever calling base because this exception in MigratableStorage will get thrown:

if (sourceUri.IsBaseOf(destinationUri))
    throw new ArgumentException("Destination provided is inside the source", destination.FullName);

I also believe at the same time that TournamentStorage's Migrate is different enough to not need to call base.

I could just be talking about some non-issue and that overriding like this is fine, but I am not sure. Hopefully it will come to light once it can be reviewed again.

# Conflicts:
#	osu.Game/IO/OsuStorage.cs
@MiraiSubject
Copy link
Contributor Author

I resolved the conflicts in an incoming commit and reran the tests locally again to make sure they didn't fail.

I thought some more about this and my comment above can actually be disregarded. The intention of the migration method is that it is supposed to be a temporary method so that existing configurations get migrated after users update the client.

For future versions users would be instructed to create their new configurations in the format of tournaments/<tournament acronym> and then edit the tournament.ini appropriately to CurrentTournament = <tournament acronym>.

The end goal is to put this functionality of adding and selecting tournaments in the UI itself.

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to go now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants