diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index e09e84def1..0378421411 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Linq.Expressions; using System.Security.Cryptography; using osu.Framework.Platform; using osu.Game.Beatmaps; @@ -58,6 +59,8 @@ namespace osu.Game.Database Hash = hash, }; beatmapSet.Metadata = metadata; + connection.Insert(beatmapSet); + connection.Insert(metadata); var maps = new List(); using (var reader = ArchiveReader.GetReader(storage, path)) { @@ -72,10 +75,11 @@ namespace osu.Game.Database // TODO: Diff beatmap metadata with set metadata and leave it here if necessary beatmap.BeatmapInfo.Metadata = null; maps.Add(beatmap.BeatmapInfo); + connection.Insert(beatmap.BeatmapInfo); } } } - connection.InsertWithChildren(beatmapSet); + connection.UpdateWithChildren(beatmapSet); BeatmapSetAdded?.Invoke(beatmapSet); } @@ -108,6 +112,17 @@ namespace osu.Game.Database { return connection.Table(); } + + public T GetWithChildren(object id) where T : class + { + return connection.GetWithChildren(id); + } + + public List GetAllWithChildren(Expression> filter = null, + bool recursive = true) where T : class + { + return connection.GetAllWithChildren(filter, recursive); + } readonly Type[] validTypes = new[] { diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index d6726840c7..78bd4408b6 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -42,6 +42,7 @@ namespace osu.Game.GameModes.Play private void addBeatmapSet(BeatmapSetInfo beatmapSet) { + beatmapSet = beatmaps.GetWithChildren(beatmapSet.BeatmapSetID); var group = new BeatmapGroup(beatmapSet); group.SetSelected += (selectedSet) => selectBeatmapSet(selectedSet); setList.Add(group);