1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Skip beatmap imports where ruleset is not present in realm

Closes #16651.

When a ruleset is not available, the `Find` call would return null. When
a null is passed to the constructor, `BeatmapInfo` would create an "osu"
ruleset, which tries to get stored to realm and fails on duplicate
primary key.

Probably need to add better safeties against this (or change that
constructor...) but this will fix the migration process.

Probably not serious enough to pull the build. This only affects
rulesets like karaoke which have custom beatmaps.
This commit is contained in:
Dean Herbert 2022-01-28 00:14:18 +09:00
parent e872877185
commit 81461be49f

View File

@ -232,6 +232,7 @@ namespace osu.Game.Database
var transaction = r.BeginWrite(); var transaction = r.BeginWrite();
int written = 0; int written = 0;
int missing = 0;
try try
{ {
@ -261,6 +262,12 @@ namespace osu.Game.Database
var ruleset = r.Find<RulesetInfo>(beatmap.RulesetInfo.ShortName); var ruleset = r.Find<RulesetInfo>(beatmap.RulesetInfo.ShortName);
var metadata = getBestMetadata(beatmap.Metadata, beatmapSet.Metadata); var metadata = getBestMetadata(beatmap.Metadata, beatmapSet.Metadata);
if (ruleset == null)
{
log($"Skipping {++missing} beatmaps with missing ruleset");
continue;
}
var realmBeatmap = new BeatmapInfo(ruleset, new BeatmapDifficulty(beatmap.BaseDifficulty), metadata) var realmBeatmap = new BeatmapInfo(ruleset, new BeatmapDifficulty(beatmap.BaseDifficulty), metadata)
{ {
DifficultyName = beatmap.DifficultyName, DifficultyName = beatmap.DifficultyName,