From 5bd91a531d37c4a89e7cc1925ca80888c81d276b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 1 Jul 2023 23:37:22 +0900 Subject: [PATCH] Tidy up comments and code --- osu.Game/Beatmaps/BeatmapImporter.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapImporter.cs b/osu.Game/Beatmaps/BeatmapImporter.cs index b0f58d029806..da987eb752d0 100644 --- a/osu.Game/Beatmaps/BeatmapImporter.cs +++ b/osu.Game/Beatmaps/BeatmapImporter.cs @@ -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 scores = realm.All().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().Where(score => score.BeatmapHash == beatmap.Hash)) + score.BeatmapInfo = beatmap; } ProcessBeatmap?.Invoke(model, parameters.Batch ? MetadataLookupScope.LocalCacheFirst : MetadataLookupScope.OnlineFirst);