Skip to content

Commit

Permalink
Tidy up comments and code
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 1, 2023
1 parent a4a9223 commit 5bd91a5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions osu.Game/Beatmaps/BeatmapImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,12 @@ protected override void PostImport(BeatmapSetInfo model, Realm realm, ImportPara
{
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.
// Scores are stored separately from beatmaps, and persisted when a beatmap is modified or deleted.
// Let's reattach any matching scores that exist in the database, based on hash.
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
foreach (var score in realm.All<ScoreInfo>().Where(score => score.BeatmapHash == beatmap.Hash))
score.BeatmapInfo = beatmap;
}

ProcessBeatmap?.Invoke(model, parameters.Batch ? MetadataLookupScope.LocalCacheFirst : MetadataLookupScope.OnlineFirst);
Expand Down

0 comments on commit 5bd91a5

Please sign in to comment.