mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Merge branch 'master' into online-beatmap-id-sanity
This commit is contained in:
commit
05e1a7a5f8
@ -25,21 +25,6 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
var context = GetContext();
|
||||
|
||||
// https://stackoverflow.com/a/10450893
|
||||
context.Database.ExecuteSqlCommand("DELETE FROM BeatmapMetadata");
|
||||
context.Database.ExecuteSqlCommand("DELETE FROM BeatmapDifficulty");
|
||||
context.Database.ExecuteSqlCommand("DELETE FROM BeatmapSetInfo");
|
||||
context.Database.ExecuteSqlCommand("DELETE FROM BeatmapSetFileInfo");
|
||||
context.Database.ExecuteSqlCommand("DELETE FROM BeatmapInfo");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a <see cref="BeatmapSetInfo"/> to the database.
|
||||
/// </summary>
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
|
||||
namespace osu.Game.Database
|
||||
@ -32,16 +31,6 @@ namespace osu.Game.Database
|
||||
queryContext = new ThreadLocal<OsuDbContext>(CreateContext);
|
||||
|
||||
Storage = storage;
|
||||
|
||||
try
|
||||
{
|
||||
Prepare();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $@"Failed to initialise the {GetType()}! Trying again with a clean database...");
|
||||
Prepare(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -50,15 +39,5 @@ namespace osu.Game.Database
|
||||
public virtual void Cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare this database for use. Tables should be created here.
|
||||
/// </summary>
|
||||
protected abstract void Prepare(bool reset = false);
|
||||
|
||||
/// <summary>
|
||||
/// Reset this database to a default state. Undo all changes to database and storage backings.
|
||||
/// </summary>
|
||||
public void Reset() => Prepare(true);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
@ -27,17 +26,6 @@ namespace osu.Game.IO
|
||||
Store = new StorageBackedResourceStore(Storage);
|
||||
}
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
if (Storage.ExistsDirectory(string.Empty))
|
||||
Storage.DeleteDirectory(string.Empty);
|
||||
|
||||
GetContext().Database.ExecuteSqlCommand("DELETE FROM FileInfo");
|
||||
}
|
||||
}
|
||||
|
||||
public FileInfo Add(Stream data, bool reference = true)
|
||||
{
|
||||
var context = GetContext();
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
@ -30,12 +29,6 @@ namespace osu.Game.Input
|
||||
|
||||
public void Register(KeyBindingInputManager manager) => insertDefaults(manager.DefaultKeyBindings);
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
if (reset)
|
||||
GetContext().Database.ExecuteSqlCommand("DELETE FROM KeyBinding");
|
||||
}
|
||||
|
||||
private void insertDefaults(IEnumerable<KeyBinding> defaults, int? rulesetId = null, int? variant = null)
|
||||
{
|
||||
var context = GetContext();
|
||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Rulesets
|
||||
@ -29,6 +28,7 @@ namespace osu.Game.Rulesets
|
||||
public RulesetStore(Func<OsuDbContext> factory)
|
||||
: base(factory)
|
||||
{
|
||||
AddMissingRulesets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -47,15 +47,10 @@ namespace osu.Game.Rulesets
|
||||
|
||||
private const string ruleset_library_prefix = "osu.Game.Rulesets";
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
protected void AddMissingRulesets()
|
||||
{
|
||||
var context = GetContext();
|
||||
|
||||
if (reset)
|
||||
{
|
||||
context.Database.ExecuteSqlCommand("DELETE FROM RulesetInfo");
|
||||
}
|
||||
|
||||
var instances = loaded_assemblies.Values.Select(r => (Ruleset)Activator.CreateInstance(r, new RulesetInfo())).ToList();
|
||||
|
||||
//add all legacy modes in correct order
|
||||
|
@ -143,9 +143,5 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
return new Replay { Frames = frames };
|
||||
}
|
||||
|
||||
protected override void Prepare(bool reset = false)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user