mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:02:54 +08:00
Automate includes of files in ArchiveModelManager use cases
This commit is contained in:
parent
acc2113027
commit
d4041d5d42
@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the storage and retrieval of Beatmaps/BeatmapSets to the database backing
|
/// Handles the storage and retrieval of Beatmaps/BeatmapSets to the database backing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BeatmapStore : MutableDatabaseBackedStore<BeatmapSetInfo>
|
public class BeatmapStore : MutableDatabaseBackedStoreWithFileIncludes<BeatmapSetInfo, BeatmapSetFileInfo>
|
||||||
{
|
{
|
||||||
public event Action<BeatmapInfo> BeatmapHidden;
|
public event Action<BeatmapInfo> BeatmapHidden;
|
||||||
public event Action<BeatmapInfo> BeatmapRestored;
|
public event Action<BeatmapInfo> BeatmapRestored;
|
||||||
@ -64,18 +64,17 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
protected override IQueryable<BeatmapSetInfo> AddIncludesForDeletion(IQueryable<BeatmapSetInfo> query) =>
|
protected override IQueryable<BeatmapSetInfo> AddIncludesForDeletion(IQueryable<BeatmapSetInfo> query) =>
|
||||||
base.AddIncludesForDeletion(query)
|
base.AddIncludesForDeletion(query)
|
||||||
.Include(s => s.Beatmaps).ThenInclude(b => b.Metadata)
|
|
||||||
.Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty)
|
|
||||||
.Include(s => s.Metadata)
|
.Include(s => s.Metadata)
|
||||||
.Include(s => s.Beatmaps).ThenInclude(b => b.Scores);
|
.Include(s => s.Beatmaps).ThenInclude(b => b.Scores)
|
||||||
|
.Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty)
|
||||||
|
.Include(s => s.Beatmaps).ThenInclude(b => b.Metadata);
|
||||||
|
|
||||||
protected override IQueryable<BeatmapSetInfo> AddIncludesForConsumption(IQueryable<BeatmapSetInfo> query) =>
|
protected override IQueryable<BeatmapSetInfo> AddIncludesForConsumption(IQueryable<BeatmapSetInfo> query) =>
|
||||||
base.AddIncludesForConsumption(query)
|
base.AddIncludesForConsumption(query)
|
||||||
.Include(s => s.Metadata)
|
.Include(s => s.Metadata)
|
||||||
.Include(s => s.Beatmaps).ThenInclude(s => s.Ruleset)
|
.Include(s => s.Beatmaps).ThenInclude(s => s.Ruleset)
|
||||||
.Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty)
|
.Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty)
|
||||||
.Include(s => s.Beatmaps).ThenInclude(b => b.Metadata)
|
.Include(s => s.Beatmaps).ThenInclude(b => b.Metadata);
|
||||||
.Include(s => s.Files).ThenInclude(f => f.FileInfo);
|
|
||||||
|
|
||||||
protected override void Purge(List<BeatmapSetInfo> items, OsuDbContext context)
|
protected override void Purge(List<BeatmapSetInfo> items, OsuDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ namespace osu.Game.Database
|
|||||||
a.Invoke();
|
a.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStore<TModel> modelStore, IIpcHost importHost = null)
|
protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore, IIpcHost importHost = null)
|
||||||
{
|
{
|
||||||
ContextFactory = contextFactory;
|
ContextFactory = contextFactory;
|
||||||
|
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
|
||||||
|
namespace osu.Game.Database
|
||||||
|
{
|
||||||
|
public abstract class MutableDatabaseBackedStoreWithFileIncludes<T, U> : MutableDatabaseBackedStore<T>
|
||||||
|
where T : class, IHasPrimaryKey, ISoftDelete, IHasFiles<U>
|
||||||
|
where U : INamedFileInfo
|
||||||
|
{
|
||||||
|
protected MutableDatabaseBackedStoreWithFileIncludes(IDatabaseContextFactory contextFactory, Storage storage = null)
|
||||||
|
: base(contextFactory, storage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IQueryable<T> AddIncludesForConsumption(IQueryable<T> query) =>
|
||||||
|
base.AddIncludesForConsumption(query)
|
||||||
|
.Include(s => s.Files).ThenInclude(f => f.FileInfo);
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ using osu.Game.Database;
|
|||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
public class ScoreStore : MutableDatabaseBackedStore<ScoreInfo>
|
public class ScoreStore : MutableDatabaseBackedStoreWithFileIncludes<ScoreInfo, ScoreFileInfo>
|
||||||
{
|
{
|
||||||
public ScoreStore(IDatabaseContextFactory factory, Storage storage)
|
public ScoreStore(IDatabaseContextFactory factory, Storage storage)
|
||||||
: base(factory, storage)
|
: base(factory, storage)
|
||||||
@ -17,7 +17,6 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
protected override IQueryable<ScoreInfo> AddIncludesForConsumption(IQueryable<ScoreInfo> query)
|
protected override IQueryable<ScoreInfo> AddIncludesForConsumption(IQueryable<ScoreInfo> query)
|
||||||
=> base.AddIncludesForConsumption(query)
|
=> base.AddIncludesForConsumption(query)
|
||||||
.Include(s => s.Files).ThenInclude(f => f.FileInfo)
|
|
||||||
.Include(s => s.Beatmap)
|
.Include(s => s.Beatmap)
|
||||||
.Include(s => s.Ruleset);
|
.Include(s => s.Ruleset);
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
public class SkinStore : MutableDatabaseBackedStore<SkinInfo>
|
public class SkinStore : MutableDatabaseBackedStoreWithFileIncludes<SkinInfo, SkinFileInfo>
|
||||||
{
|
{
|
||||||
public SkinStore(DatabaseContextFactory contextFactory, Storage storage = null)
|
public SkinStore(DatabaseContextFactory contextFactory, Storage storage = null)
|
||||||
: base(contextFactory, storage)
|
: base(contextFactory, storage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IQueryable<SkinInfo> AddIncludesForConsumption(IQueryable<SkinInfo> query) =>
|
|
||||||
base.AddIncludesForConsumption(query)
|
|
||||||
.Include(s => s.Files).ThenInclude(f => f.FileInfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user