From 56fe69852dc0c5402ebf728c30d98439468a0b9b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Jan 2017 18:13:06 +0900 Subject: [PATCH] Change beatmap database reset logic to only run a maximum of once. --- osu.Game/Database/BeatmapDatabase.cs | 32 ++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index de63e7cdca..99a8867636 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -36,25 +36,39 @@ public BeatmapDatabase(BasicStorage storage, BasicGameHost importHost = null) if (connection == null) { - retry: try { - connection = storage.GetDatabase(@"beatmaps"); - connection.CreateTable(); - connection.CreateTable(); - connection.CreateTable(); - connection.CreateTable(); + connection = prepareConnection(); } catch { - Debug.WriteLine(@"Beatmap database was unable to be migrated; starting fresh!"); - connection?.Close(); + Console.WriteLine(@"Failed to initialise the beatmap database! Trying again with a clean database..."); storage.DeleteDatabase(@"beatmaps"); - goto retry; + 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())