mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Add maximum try count before bailing
This commit is contained in:
@ -90,28 +90,7 @@ namespace osu.Game
|
|||||||
dependencies.Cache(this);
|
dependencies.Cache(this);
|
||||||
dependencies.Cache(LocalConfig);
|
dependencies.Cache(LocalConfig);
|
||||||
|
|
||||||
try
|
runMigrations();
|
||||||
{
|
|
||||||
using (var context = contextFactory.GetContext())
|
|
||||||
context.Migrate();
|
|
||||||
}
|
|
||||||
catch (MigrationFailedException)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var context = contextFactory.GetContext())
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
using (var context = contextFactory.GetContext())
|
|
||||||
context.Migrate();
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies.Cache(API = new APIAccess
|
dependencies.Cache(API = new APIAccess
|
||||||
{
|
{
|
||||||
@ -183,6 +162,38 @@ namespace osu.Game
|
|||||||
FileStore.Cleanup();
|
FileStore.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void runMigrations()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var context = contextFactory.GetContext())
|
||||||
|
context.Migrate();
|
||||||
|
}
|
||||||
|
catch (MigrationFailedException)
|
||||||
|
{
|
||||||
|
// if we failed, let's delete the database and start fresh.
|
||||||
|
// todo: we probably want a better (non-destructive) migrations/recovery process at a later point than this.
|
||||||
|
int retries = 20;
|
||||||
|
while (retries-- > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var context = contextFactory.GetContext())
|
||||||
|
{
|
||||||
|
context.Database.EnsureDeleted();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var context = contextFactory.GetContext())
|
||||||
|
context.Migrate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private WorkingBeatmap lastBeatmap;
|
private WorkingBeatmap lastBeatmap;
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(APIAccess api, APIState state)
|
||||||
|
Reference in New Issue
Block a user