Move 'transferCollections' to a shared location

This commit is contained in:
pfg
2022-10-10 21:45:33 -04:00
parent 7726dda975
commit de8d485305
3 changed files with 14 additions and 12 deletions

View File

@ -8,6 +8,7 @@ using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Testing;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Collections;
using osu.Game.Database;
using osu.Game.Models;
using osu.Game.Online.API.Requests.Responses;
@ -213,6 +214,17 @@ namespace osu.Game.Beatmaps
return fileHashX == fileHashY;
}
public void transferCollectionsFrom(Realm realm, string oldMd5Hash)
{
var collections = realm.All<BeatmapCollection>().AsEnumerable().Where(c => c.BeatmapMD5Hashes.Contains(oldMd5Hash));
foreach (var c in collections)
{
c.BeatmapMD5Hashes.Remove(oldMd5Hash);
c.BeatmapMD5Hashes.Add(MD5Hash);
}
}
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
IBeatmapSetInfo? IBeatmapInfo.BeatmapSet => BeatmapSet;
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;