1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:07:52 +08:00

Move score re-attach to PostImport

This commit is contained in:
Dean Herbert 2023-07-01 23:12:04 +09:00
parent 8d25e2c3e1
commit a4a9223726

View File

@ -200,21 +200,22 @@ namespace osu.Game.Beatmaps
LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineID ({beatmapSet.OnlineID}). It will be disassociated and marked for deletion.");
}
}
}
protected override void PostImport(BeatmapSetInfo model, Realm realm, ImportParameters parameters)
{
base.PostImport(model, realm, parameters);
//Because of specific score storing in Osu! database, it can already contain scores for imported beatmap.
//To restore scores we need to manually reassign them to new/re-exported beatmap.
foreach (BeatmapInfo beatmap in beatmapSet.Beatmaps)
foreach (BeatmapInfo beatmap in model.Beatmaps)
{
IQueryable<ScoreInfo> scores = realm.All<ScoreInfo>().Where(score => score.BeatmapHash == beatmap.Hash);
if (scores.Any())
scores.ForEach(score => score.BeatmapInfo = beatmap); //We intentionally ignore BeatmapHash because we checked hash equality
}
}
protected override void PostImport(BeatmapSetInfo model, Realm realm, ImportParameters parameters)
{
base.PostImport(model, realm, parameters);
ProcessBeatmap?.Invoke(model, parameters.Batch ? MetadataLookupScope.LocalCacheFirst : MetadataLookupScope.OnlineFirst);
}