mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 15:33:05 +08:00
Merge pull request #19121 from peppy/fix-realm-multiple-online-id
Ensure that multiple `BeatmapSetInfo` with same `OnlineID` don't cause import failures
This commit is contained in:
commit
d8ae1151c6
@ -80,9 +80,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
if (beatmapSet.OnlineID > 0)
|
if (beatmapSet.OnlineID > 0)
|
||||||
{
|
{
|
||||||
var existingSetWithSameOnlineID = realm.All<BeatmapSetInfo>().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID);
|
// OnlineID should really be unique, but to avoid catastrophic failure let's iterate just to be sure.
|
||||||
|
foreach (var existingSetWithSameOnlineID in realm.All<BeatmapSetInfo>().Where(b => b.OnlineID == beatmapSet.OnlineID))
|
||||||
if (existingSetWithSameOnlineID != null)
|
|
||||||
{
|
{
|
||||||
existingSetWithSameOnlineID.DeletePending = true;
|
existingSetWithSameOnlineID.DeletePending = true;
|
||||||
existingSetWithSameOnlineID.OnlineID = -1;
|
existingSetWithSameOnlineID.OnlineID = -1;
|
||||||
@ -90,7 +89,7 @@ namespace osu.Game.Beatmaps
|
|||||||
foreach (var b in existingSetWithSameOnlineID.Beatmaps)
|
foreach (var b in existingSetWithSameOnlineID.Beatmaps)
|
||||||
b.OnlineID = -1;
|
b.OnlineID = -1;
|
||||||
|
|
||||||
LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineID ({beatmapSet.OnlineID}). It will be deleted.");
|
LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineID ({beatmapSet.OnlineID}). It will be disassociated and marked for deletion.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user