mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Change beatmap database reset logic to only run a maximum of once.
This commit is contained in:
@ -36,25 +36,39 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
{
|
{
|
||||||
retry:
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = storage.GetDatabase(@"beatmaps");
|
connection = prepareConnection();
|
||||||
connection.CreateTable<BeatmapMetadata>();
|
|
||||||
connection.CreateTable<BaseDifficulty>();
|
|
||||||
connection.CreateTable<BeatmapSetInfo>();
|
|
||||||
connection.CreateTable<BeatmapInfo>();
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.WriteLine(@"Beatmap database was unable to be migrated; starting fresh!");
|
Console.WriteLine(@"Failed to initialise the beatmap database! Trying again with a clean database...");
|
||||||
connection?.Close();
|
|
||||||
storage.DeleteDatabase(@"beatmaps");
|
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()
|
public void Reset()
|
||||||
{
|
{
|
||||||
foreach (var setInfo in Query<BeatmapSetInfo>())
|
foreach (var setInfo in Query<BeatmapSetInfo>())
|
||||||
|
Reference in New Issue
Block a user