From b9ef32b09bfb137eafaa034f2cd3e5524f496a4d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Feb 2018 16:31:42 +0900 Subject: [PATCH] Further xmldoc and restoring of Cleanup method --- osu.Game/Database/ArchiveModelManager.cs | 2 +- osu.Game/Database/DatabaseBackedStore.cs | 2 +- .../Database/MutableDatabaseBackedStore.cs | 34 +++++++++++++++++++ osu.Game/IO/FileStore.cs | 2 +- osu.Game/OsuGameBase.cs | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 1b37e7e76c..20f90a248b 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -63,7 +63,7 @@ namespace osu.Game.Database if (importHost != null) ipc = new ArchiveImportIPCChannel(importHost, this); - ModelStore.PurgeDeletable(); + ModelStore.Cleanup(); } /// diff --git a/osu.Game/Database/DatabaseBackedStore.cs b/osu.Game/Database/DatabaseBackedStore.cs index 6109475690..0fafb77339 100644 --- a/osu.Game/Database/DatabaseBackedStore.cs +++ b/osu.Game/Database/DatabaseBackedStore.cs @@ -48,7 +48,7 @@ namespace osu.Game.Database /// /// Perform any common clean-up tasks. Should be run when idle, or whenever necessary. /// - public virtual void PurgeDeletable() + public virtual void Cleanup() { } } diff --git a/osu.Game/Database/MutableDatabaseBackedStore.cs b/osu.Game/Database/MutableDatabaseBackedStore.cs index 96bc48fd8a..95d3dfc582 100644 --- a/osu.Game/Database/MutableDatabaseBackedStore.cs +++ b/osu.Game/Database/MutableDatabaseBackedStore.cs @@ -26,6 +26,10 @@ namespace osu.Game.Database /// public IQueryable ConsumableItems => AddIncludesForConsumption(ContextFactory.Get().Set()); + /// + /// Add a to the database. + /// + /// The item to add. public void Add(T item) { using (var usage = ContextFactory.GetForWrite()) @@ -51,6 +55,10 @@ namespace osu.Game.Database ItemAdded?.Invoke(item); } + /// + /// Delete a from the database. + /// + /// The item to delete. public bool Delete(T item) { using (ContextFactory.GetForWrite()) @@ -65,6 +73,10 @@ namespace osu.Game.Database return true; } + /// + /// Restore a from a deleted state. + /// + /// The item to undelete. public bool Undelete(T item) { using (ContextFactory.GetForWrite()) @@ -79,12 +91,34 @@ namespace osu.Game.Database return true; } + /// + /// Allow implementations to add database-side includes or constraints when querying for consumption of items. + /// + /// The input query. + /// A potentially modified output query. protected virtual IQueryable AddIncludesForConsumption(IQueryable query) => query; + /// + /// Allow implementations to add database-side includes or constraints when deleting items. + /// Included properties could then be subsequently deleted by overriding . + /// + /// The input query. + /// A potentially modified output query. protected virtual IQueryable AddIncludesForDeletion(IQueryable query) => query; + /// + /// Called when removing an item completely from the database. + /// + /// The items to be purged. + /// The write context which can be used to perform subsequent deletions. protected virtual void Purge(List items, OsuDbContext context) => context.RemoveRange(items); + public override void Cleanup() + { + base.Cleanup(); + PurgeDeletable(); + } + /// /// Purge items in a pending delete state. /// diff --git a/osu.Game/IO/FileStore.cs b/osu.Game/IO/FileStore.cs index 6f262fd8fa..ab81ba4851 100644 --- a/osu.Game/IO/FileStore.cs +++ b/osu.Game/IO/FileStore.cs @@ -90,7 +90,7 @@ namespace osu.Game.IO } } - public override void PurgeDeletable() + public override void Cleanup() { using (var usage = ContextFactory.GetForWrite()) { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index dba0250007..de2a4d0b82 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -177,7 +177,7 @@ namespace osu.Game API.Register(this); - FileStore.PurgeDeletable(); + FileStore.Cleanup(); } private void runMigrations()