mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Revert database-side changes
This commit is contained in:
parent
1463ff2886
commit
ca5f2bcd4c
@ -852,39 +852,6 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestItemRemovedShouldPassConsumableBeatmapSet()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(ImportBeatmapTest)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = LoadOsuIntoHost(host);
|
||||
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||
|
||||
var removedQueue = new Queue<BeatmapSetInfo>();
|
||||
manager.ItemRemoved.BindValueChanged(evt =>
|
||||
{
|
||||
if (evt.NewValue.TryGetTarget(out var target))
|
||||
removedQueue.Enqueue(target);
|
||||
});
|
||||
|
||||
var imported = await LoadOszIntoOsu(osu);
|
||||
deleteBeatmapSet(imported, osu);
|
||||
|
||||
Assert.That(removedQueue.Count, Is.EqualTo(1));
|
||||
|
||||
var removedItem = removedQueue.Single();
|
||||
Assert.That(removedItem.Metadata, Is.EqualTo(imported.Metadata));
|
||||
Assert.That(removedItem.Beatmaps, Is.EquivalentTo(imported.Beatmaps));
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
||||
{
|
||||
var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
|
||||
|
@ -75,7 +75,7 @@ namespace osu.Game.Database
|
||||
|
||||
protected readonly IDatabaseContextFactory ContextFactory;
|
||||
|
||||
protected readonly MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> ModelStore;
|
||||
protected readonly MutableDatabaseBackedStore<TModel> ModelStore;
|
||||
|
||||
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
||||
private ArchiveImportIPCChannel ipc;
|
||||
@ -491,7 +491,7 @@ namespace osu.Game.Database
|
||||
using (ContextFactory.GetForWrite())
|
||||
{
|
||||
// re-fetch the model on the import context.
|
||||
var foundModel = ModelStore.ConsumableItems.SingleOrDefault(i => i.ID == item.ID);
|
||||
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).FirstOrDefault(s => s.ID == item.ID);
|
||||
|
||||
if (foundModel == null || foundModel.DeletePending) return false;
|
||||
|
||||
@ -730,6 +730,8 @@ namespace osu.Game.Database
|
||||
yield return f.Filename;
|
||||
}
|
||||
|
||||
private DbSet<TModel> queryModel() => ContextFactory.Get().Set<TModel>();
|
||||
|
||||
protected virtual string HumanisedModelName => $"{typeof(TModel).Name.Replace("Info", "").ToLower()}";
|
||||
|
||||
#region Event handling / delaying
|
||||
|
Loading…
Reference in New Issue
Block a user