mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
prevent inserting duplicate metadata
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -32,6 +33,15 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
var context = GetContext();
|
var context = GetContext();
|
||||||
|
|
||||||
|
foreach (var beatmap in beatmapSet.Beatmaps.Where(b => b.Metadata != null))
|
||||||
|
{
|
||||||
|
var contextMetadata = context.Set<BeatmapMetadata>().Local.SingleOrDefault(e => e.Equals(beatmap.Metadata));
|
||||||
|
if (contextMetadata != null)
|
||||||
|
beatmap.Metadata = contextMetadata;
|
||||||
|
else
|
||||||
|
context.BeatmapMetadata.Attach(beatmap.Metadata);
|
||||||
|
}
|
||||||
|
|
||||||
context.BeatmapSetInfo.Attach(beatmapSet);
|
context.BeatmapSetInfo.Attach(beatmapSet);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user