1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Fix cascade insert

This commit is contained in:
Drew DeVault 2016-10-19 12:51:18 -04:00
parent 641855c790
commit 3ee0bf2b80
2 changed files with 17 additions and 1 deletions

View File

@ -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<BeatmapInfo>();
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);
}
@ -109,6 +113,17 @@ namespace osu.Game.Database
return connection.Table<T>();
}
public T GetWithChildren<T>(object id) where T : class
{
return connection.GetWithChildren<T>(id);
}
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null,
bool recursive = true) where T : class
{
return connection.GetAllWithChildren<T>(filter, recursive);
}
readonly Type[] validTypes = new[]
{
typeof(BeatmapSetInfo),

View File

@ -42,6 +42,7 @@ namespace osu.Game.GameModes.Play
private void addBeatmapSet(BeatmapSetInfo beatmapSet)
{
beatmapSet = beatmaps.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
var group = new BeatmapGroup(beatmapSet);
group.SetSelected += (selectedSet) => selectBeatmapSet(selectedSet);
setList.Add(group);