diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index eda5f1b9a3..99a8867636 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -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(); - connection.CreateTable(); - connection.CreateTable(); - connection.CreateTable(); + 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(); + conn.CreateTable(); + conn.CreateTable(); + conn.CreateTable(); + } + catch + { + conn.Close(); + throw; + } + + return conn; + } + public void Reset() { foreach (var setInfo in Query())