1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 16:02:56 +08: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:
Dean Herbert 2017-01-23 21:43:52 +09:00 committed by GitHub
commit 23938a810b

View File

@ -4,6 +4,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
@ -35,14 +36,39 @@ namespace osu.Game.Database
if (connection == null)
{
connection = storage.GetDatabase(@"beatmaps");
connection.CreateTable<BeatmapMetadata>();
connection.CreateTable<BaseDifficulty>();
connection.CreateTable<BeatmapSetInfo>();
connection.CreateTable<BeatmapInfo>();
try
{
connection = prepareConnection();
}
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()
{
foreach (var setInfo in Query<BeatmapSetInfo>())