mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09: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.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -410,11 +411,28 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
Logger.Log($@"Migrating osu! data from ""{Storage.GetFullPath(string.Empty)}"" to ""{path}""...");
|
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));
|
(Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
realmBlocker?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Logger.Log(@"Migration complete!");
|
Logger.Log(@"Migration complete!");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user