mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Merge pull request #292 from peppy/general-fixes
Reset the beatmap database when it can't be read, rather than hard failing.
This commit is contained in:
commit
23938a810b
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
@ -35,14 +36,39 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
{
|
{
|
||||||
connection = storage.GetDatabase(@"beatmaps");
|
try
|
||||||
connection.CreateTable<BeatmapMetadata>();
|
{
|
||||||
connection.CreateTable<BaseDifficulty>();
|
connection = prepareConnection();
|
||||||
connection.CreateTable<BeatmapSetInfo>();
|
}
|
||||||
connection.CreateTable<BeatmapInfo>();
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine(@"Failed to initialise the beatmap database! Trying again with a clean database...");
|
||||||
|
storage.DeleteDatabase(@"beatmaps");
|
||||||
|
connection = prepareConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SQLiteConnection prepareConnection()
|
||||||
|
{
|
||||||
|
var conn = storage.GetDatabase(@"beatmaps");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
conn.CreateTable<BeatmapMetadata>();
|
||||||
|
conn.CreateTable<BaseDifficulty>();
|
||||||
|
conn.CreateTable<BeatmapSetInfo>();
|
||||||
|
conn.CreateTable<BeatmapInfo>();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
foreach (var setInfo in Query<BeatmapSetInfo>())
|
foreach (var setInfo in Query<BeatmapSetInfo>())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user