mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 08:52:54 +08:00
Further xmldoc and restoring of Cleanup method
This commit is contained in:
parent
1b13be1372
commit
b9ef32b09b
@ -63,7 +63,7 @@ namespace osu.Game.Database
|
|||||||
if (importHost != null)
|
if (importHost != null)
|
||||||
ipc = new ArchiveImportIPCChannel(importHost, this);
|
ipc = new ArchiveImportIPCChannel(importHost, this);
|
||||||
|
|
||||||
ModelStore.PurgeDeletable();
|
ModelStore.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform any common clean-up tasks. Should be run when idle, or whenever necessary.
|
/// Perform any common clean-up tasks. Should be run when idle, or whenever necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void PurgeDeletable()
|
public virtual void Cleanup()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,10 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IQueryable<T> ConsumableItems => AddIncludesForConsumption(ContextFactory.Get().Set<T>());
|
public IQueryable<T> ConsumableItems => AddIncludesForConsumption(ContextFactory.Get().Set<T>());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a <see cref="T"/> to the database.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to add.</param>
|
||||||
public void Add(T item)
|
public void Add(T item)
|
||||||
{
|
{
|
||||||
using (var usage = ContextFactory.GetForWrite())
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
@ -51,6 +55,10 @@ namespace osu.Game.Database
|
|||||||
ItemAdded?.Invoke(item);
|
ItemAdded?.Invoke(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a <see cref="T"/> from the database.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to delete.</param>
|
||||||
public bool Delete(T item)
|
public bool Delete(T item)
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
@ -65,6 +73,10 @@ namespace osu.Game.Database
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restore a <see cref="T"/> from a deleted state.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to undelete.</param>
|
||||||
public bool Undelete(T item)
|
public bool Undelete(T item)
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
@ -79,12 +91,34 @@ namespace osu.Game.Database
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allow implementations to add database-side includes or constraints when querying for consumption of items.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query">The input query.</param>
|
||||||
|
/// <returns>A potentially modified output query.</returns>
|
||||||
protected virtual IQueryable<T> AddIncludesForConsumption(IQueryable<T> query) => query;
|
protected virtual IQueryable<T> AddIncludesForConsumption(IQueryable<T> query) => query;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allow implementations to add database-side includes or constraints when deleting items.
|
||||||
|
/// Included properties could then be subsequently deleted by overriding <see cref="Purge"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query">The input query.</param>
|
||||||
|
/// <returns>A potentially modified output query.</returns>
|
||||||
protected virtual IQueryable<T> AddIncludesForDeletion(IQueryable<T> query) => query;
|
protected virtual IQueryable<T> AddIncludesForDeletion(IQueryable<T> query) => query;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when removing an item completely from the database.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">The items to be purged.</param>
|
||||||
|
/// <param name="context">The write context which can be used to perform subsequent deletions.</param>
|
||||||
protected virtual void Purge(List<T> items, OsuDbContext context) => context.RemoveRange(items);
|
protected virtual void Purge(List<T> items, OsuDbContext context) => context.RemoveRange(items);
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
base.Cleanup();
|
||||||
|
PurgeDeletable();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Purge items in a pending delete state.
|
/// Purge items in a pending delete state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -90,7 +90,7 @@ namespace osu.Game.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PurgeDeletable()
|
public override void Cleanup()
|
||||||
{
|
{
|
||||||
using (var usage = ContextFactory.GetForWrite())
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
API.Register(this);
|
API.Register(this);
|
||||||
|
|
||||||
FileStore.PurgeDeletable();
|
FileStore.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runMigrations()
|
private void runMigrations()
|
||||||
|
Loading…
Reference in New Issue
Block a user