From 671475f3b40981f2105283da8aadec8a86b3952a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Feb 2018 15:51:59 +0900 Subject: [PATCH] Ensure undeleted items are populated with includes before firing events --- osu.Game/Database/DatabaseBackedStore.cs | 3 +-- osu.Game/Database/MutableDatabaseBackedStore.cs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Database/DatabaseBackedStore.cs b/osu.Game/Database/DatabaseBackedStore.cs index a1ed992f03..6109475690 100644 --- a/osu.Game/Database/DatabaseBackedStore.cs +++ b/osu.Game/Database/DatabaseBackedStore.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; using osu.Framework.Platform; @@ -23,7 +22,7 @@ namespace osu.Game.Database /// The object to use as a reference when negotiating a local instance. /// An optional lookup source which will be used to query and populate a freshly retrieved replacement. If not provided, the refreshed object will still be returned but will not have any includes. /// A valid EF-stored type. - protected virtual void Refresh(ref T obj, IEnumerable lookupSource = null) where T : class, IHasPrimaryKey + protected virtual void Refresh(ref T obj, IQueryable lookupSource = null) where T : class, IHasPrimaryKey { using (var usage = ContextFactory.GetForWrite()) { diff --git a/osu.Game/Database/MutableDatabaseBackedStore.cs b/osu.Game/Database/MutableDatabaseBackedStore.cs index 887f568864..01fcfbfe43 100644 --- a/osu.Game/Database/MutableDatabaseBackedStore.cs +++ b/osu.Game/Database/MutableDatabaseBackedStore.cs @@ -53,7 +53,6 @@ namespace osu.Game.Database Refresh(ref item); if (item.DeletePending) return false; - item.DeletePending = true; } @@ -65,10 +64,9 @@ namespace osu.Game.Database { using (ContextFactory.GetForWrite()) { - Refresh(ref item); + Refresh(ref item, ConsumableItems); if (!item.DeletePending) return false; - item.DeletePending = false; } @@ -76,6 +74,8 @@ namespace osu.Game.Database return true; } + protected virtual IQueryable AddIncludesForConsumption(IQueryable query) => query; + protected virtual IQueryable AddIncludesForDeletion(IQueryable query) => query; protected virtual void Purge(List items, OsuDbContext context)