From 9b1ed5b3aaca927ef41ec637a07405a47e60b115 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Oct 2017 23:33:27 +0900 Subject: [PATCH] Keep trying until delete succeeds Turns out it can fail if file handles are still open. --- osu.Game/OsuGameBase.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index e7ad77d099..4a80a0fa06 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -97,8 +97,18 @@ namespace osu.Game } catch (MigrationFailedException) { - using (var context = contextFactory.GetContext()) - context.Database.EnsureDeleted(); + while (true) + { + try + { + using (var context = contextFactory.GetContext()) + { + context.Database.EnsureDeleted(); + break; + } + } + catch { } + } using (var context = contextFactory.GetContext()) context.Migrate(); }