Reset the beatmap database when it can't be read, rather than hard failing.

This commit is contained in:
Dean Herbert
2017-01-23 13:02:03 +09:00
parent 2025e8ef71
commit ef8347fe53

View File

@ -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;
@ -34,6 +35,9 @@ namespace osu.Game.Database
ipc = new BeatmapImporter(importHost, this); ipc = new BeatmapImporter(importHost, this);
if (connection == null) if (connection == null)
{
retry:
try
{ {
connection = storage.GetDatabase(@"beatmaps"); connection = storage.GetDatabase(@"beatmaps");
connection.CreateTable<BeatmapMetadata>(); connection.CreateTable<BeatmapMetadata>();
@ -41,6 +45,14 @@ namespace osu.Game.Database
connection.CreateTable<BeatmapSetInfo>(); connection.CreateTable<BeatmapSetInfo>();
connection.CreateTable<BeatmapInfo>(); connection.CreateTable<BeatmapInfo>();
} }
catch
{
Debug.WriteLine(@"Beatmap database was unable to be migrated; starting fresh!");
connection?.Close();
storage.DeleteDatabase(@"beatmaps");
goto retry;
}
}
} }
public void Reset() public void Reset()