mirror of https://github.com/ppy/osu
Change beatmap database reset logic to only run a maximum of once.
This commit is contained in:
parent
ef8347fe53
commit
56fe69852d
|
@ -36,25 +36,39 @@ public BeatmapDatabase(BasicStorage storage, BasicGameHost importHost = null)
|
|||
|
||||
if (connection == null)
|
||||
{
|
||||
retry:
|
||||
try
|
||||
{
|
||||
connection = storage.GetDatabase(@"beatmaps");
|
||||
connection.CreateTable<BeatmapMetadata>();
|
||||
connection.CreateTable<BaseDifficulty>();
|
||||
connection.CreateTable<BeatmapSetInfo>();
|
||||
connection.CreateTable<BeatmapInfo>();
|
||||
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<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>())
|
||||
|
|
Loading…
Reference in New Issue