mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Fix migration blocking code running on the wrong thread
This commit is contained in:
parent
f43badabf4
commit
0df9ab3eec
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
@ -410,11 +411,28 @@ namespace osu.Game
|
||||
{
|
||||
Logger.Log($@"Migrating osu! data from ""{Storage.GetFullPath(string.Empty)}"" to ""{path}""...");
|
||||
|
||||
using (realmFactory.BlockAllOperations())
|
||||
IDisposable realmBlocker = null;
|
||||
|
||||
try
|
||||
{
|
||||
contextFactory.FlushConnections();
|
||||
ManualResetEventSlim readyToRun = new ManualResetEventSlim();
|
||||
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
realmBlocker = realmFactory.BlockAllOperations();
|
||||
contextFactory.FlushConnections();
|
||||
|
||||
readyToRun.Set();
|
||||
}, false);
|
||||
|
||||
readyToRun.Wait();
|
||||
|
||||
(Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
|
||||
}
|
||||
finally
|
||||
{
|
||||
realmBlocker?.Dispose();
|
||||
}
|
||||
|
||||
Logger.Log(@"Migration complete!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user