mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 00:02:56 +08:00
Pass the full EF context rather than a legacy RulesetStore
This commit is contained in:
parent
f264b128c2
commit
505fede44d
@ -14,7 +14,6 @@ using osu.Framework.Statistics;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Models;
|
using osu.Game.Models;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using Realms;
|
using Realms;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
@ -33,7 +32,7 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly string Filename;
|
public readonly string Filename;
|
||||||
|
|
||||||
private readonly RulesetStore? rulesets;
|
private readonly IDatabaseContextFactory? efContextFactory;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version history:
|
/// Version history:
|
||||||
@ -77,10 +76,10 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RealmContextFactory(Storage storage, string filename, RulesetStore? rulesets = null)
|
public RealmContextFactory(Storage storage, string filename, IDatabaseContextFactory? efContextFactory = null)
|
||||||
{
|
{
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.rulesets = rulesets;
|
this.efContextFactory = efContextFactory;
|
||||||
|
|
||||||
Filename = filename;
|
Filename = filename;
|
||||||
|
|
||||||
@ -252,7 +251,7 @@ namespace osu.Game.Database
|
|||||||
var newItem = newSettings.ElementAt(i);
|
var newItem = newSettings.ElementAt(i);
|
||||||
|
|
||||||
long rulesetId = oldItem.RulesetID;
|
long rulesetId = oldItem.RulesetID;
|
||||||
string? rulesetName = rulesets?.GetRuleset((int)rulesetId)?.ShortName;
|
string? rulesetName = getRulesetShortNameFromLegacyID(rulesetId);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rulesetName))
|
if (string.IsNullOrEmpty(rulesetName))
|
||||||
migration.NewRealm.Remove(newItem);
|
migration.NewRealm.Remove(newItem);
|
||||||
@ -264,6 +263,15 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string? getRulesetShortNameFromLegacyID(long rulesetId)
|
||||||
|
{
|
||||||
|
if (efContextFactory == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
using (var efContext = efContextFactory.Get())
|
||||||
|
return efContext.RulesetInfo.First(r => r.ID == rulesetId)?.ShortName;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Flush any active contexts and block any further writes.
|
/// Flush any active contexts and block any further writes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -192,7 +192,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory, Storage));
|
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory, Storage));
|
||||||
|
|
||||||
dependencies.Cache(realmFactory = new RealmContextFactory(Storage, "client", RulesetStore));
|
dependencies.Cache(realmFactory = new RealmContextFactory(Storage, "client", contextFactory));
|
||||||
|
|
||||||
dependencies.CacheAs(Storage);
|
dependencies.CacheAs(Storage);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user