1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-27 15:23:22 +08:00

Merge pull request #16627 from peppy/fix-ruleset-import-failure

Fix realm migration failures with presence of databased EF rulesets that don't exist on disk
This commit is contained in:
Dan Balasescu 2022-01-26 18:59:20 +09:00 committed by GitHub
commit f3924522a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -286,6 +286,7 @@ namespace osu.Game.Database
var transaction = r.BeginWrite();
int written = 0;
int missing = 0;
try
{
@ -300,6 +301,13 @@ namespace osu.Game.Database
var beatmap = r.All<BeatmapInfo>().First(b => b.Hash == score.BeatmapInfo.Hash);
var ruleset = r.Find<RulesetInfo>(score.Ruleset.ShortName);
if (ruleset == null)
{
log($"Skipping {++missing} scores with missing ruleset");
continue;
}
var user = new RealmUser
{
OnlineID = score.User.OnlineID,

View File

@ -28,21 +28,15 @@ namespace osu.Game.Rulesets
public Ruleset CreateInstance()
{
if (!Available)
throw new RulesetLoadException(@"Ruleset not available");
return null;
var type = Type.GetType(InstantiationInfo);
if (type == null)
throw new RulesetLoadException(@"Type lookup failure");
return null;
var ruleset = Activator.CreateInstance(type) as Ruleset;
if (ruleset == null)
throw new RulesetLoadException(@"Instantiation failure");
// overwrite the pre-populated RulesetInfo with a potentially database attached copy.
// ruleset.RulesetInfo = this;
return ruleset;
}