1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 19:32:55 +08:00

Use RealmContextFactory instead of EF

This commit is contained in:
Dean Herbert 2021-11-23 13:24:26 +09:00
parent 83cbee39de
commit 89d6ffa7f3
4 changed files with 9 additions and 15 deletions

View File

@ -167,7 +167,7 @@ namespace osu.Game.Tests.Online
public Task<ILive<BeatmapSetInfo>> CurrentImportTask { get; private set; } public Task<ILive<BeatmapSetInfo>> CurrentImportTask { get; private set; }
public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null) public TestBeatmapManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null)
: base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap) : base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
{ {
} }

View File

@ -40,7 +40,7 @@ namespace osu.Game.Beatmaps
private readonly WorkingBeatmapCache workingBeatmapCache; private readonly WorkingBeatmapCache workingBeatmapCache;
private readonly BeatmapOnlineLookupQueue onlineBeatmapLookupQueue; private readonly BeatmapOnlineLookupQueue onlineBeatmapLookupQueue;
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost host = null, WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false) public BeatmapManager(Storage storage, RealmContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost host = null, WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
{ {
var userResources = new FileStore(contextFactory, storage).Store; var userResources = new FileStore(contextFactory, storage).Store;

View File

@ -30,7 +30,7 @@ namespace osu.Game.Scoring
private readonly OsuConfigManager configManager; private readonly OsuConfigManager configManager;
private readonly ScoreModelManager scoreModelManager; private readonly ScoreModelManager scoreModelManager;
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, IDatabaseContextFactory contextFactory, Scheduler scheduler, public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmContextFactory contextFactory, Scheduler scheduler,
IIpcHost importHost = null, Func<BeatmapDifficultyCache> difficulties = null, OsuConfigManager configManager = null) IIpcHost importHost = null, Func<BeatmapDifficultyCache> difficulties = null, OsuConfigManager configManager = null)
{ {
this.scheduler = scheduler; this.scheduler = scheduler;

View File

@ -73,9 +73,9 @@ namespace osu.Game.Tests.Visual
/// <remarks> /// <remarks>
/// In interactive runs (ie. VisualTests) this will use the user's database if <see cref="UseFreshStoragePerRun"/> is not set to <c>true</c>. /// In interactive runs (ie. VisualTests) this will use the user's database if <see cref="UseFreshStoragePerRun"/> is not set to <c>true</c>.
/// </remarks> /// </remarks>
protected DatabaseContextFactory ContextFactory => contextFactory.Value; protected RealmContextFactory ContextFactory => contextFactory.Value;
private Lazy<DatabaseContextFactory> contextFactory; private Lazy<RealmContextFactory> contextFactory;
/// <summary> /// <summary>
/// Whether a fresh storage should be initialised per test (method) run. /// Whether a fresh storage should be initialised per test (method) run.
@ -117,14 +117,7 @@ namespace osu.Game.Tests.Visual
Resources = parent.Get<OsuGameBase>().Resources; Resources = parent.Get<OsuGameBase>().Resources;
contextFactory = new Lazy<DatabaseContextFactory>(() => contextFactory = new Lazy<RealmContextFactory>(() => new RealmContextFactory(LocalStorage, "client"));
{
var factory = new DatabaseContextFactory(LocalStorage);
using (var usage = factory.Get())
usage.Migrate();
return factory;
});
RecycleLocalStorage(false); RecycleLocalStorage(false);
@ -301,8 +294,9 @@ namespace osu.Game.Tests.Visual
if (MusicController?.TrackLoaded == true) if (MusicController?.TrackLoaded == true)
MusicController.Stop(); MusicController.Stop();
if (contextFactory?.IsValueCreated == true) // TODO: what should we do here, if anything? should we use an in-memory realm in this instance?
contextFactory.Value.ResetDatabase(); // if (contextFactory?.IsValueCreated == true)
// contextFactory.Value.ResetDatabase();
RecycleLocalStorage(true); RecycleLocalStorage(true);
} }