1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:13:18 +08:00

Correctly close context before attempting migration

This commit is contained in:
Dean Herbert 2021-01-21 19:02:09 +09:00
parent d2bf3a5805
commit 34a7ce912e
2 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,3 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Threading;
using osu.Framework.Graphics;
@ -77,7 +74,7 @@ namespace osu.Game.Database
{
base.Update();
if (Context.Refresh())
if (context?.Refresh() == true)
refreshes.Value++;
}
@ -107,8 +104,7 @@ namespace osu.Game.Database
{
base.Dispose(isDisposing);
context?.Dispose();
context = null;
FlushConnections();
}
/// <summary>
@ -152,5 +148,14 @@ namespace osu.Game.Database
pending_writes.Value--;
}
}
public void FlushConnections()
{
var previousContext = context;
context = null;
previousContext?.Dispose();
while (previousContext?.IsClosed == false)
Thread.Sleep(50);
}
}
}

View File

@ -513,6 +513,7 @@ namespace osu.Game
public void Migrate(string path)
{
contextFactory.FlushConnections();
realmFactory.FlushConnections();
(Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
}
}