mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Correctly close context before attempting migration
This commit is contained in:
parent
d2bf3a5805
commit
34a7ce912e
@ -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;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -77,7 +74,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (Context.Refresh())
|
if (context?.Refresh() == true)
|
||||||
refreshes.Value++;
|
refreshes.Value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +104,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
context?.Dispose();
|
FlushConnections();
|
||||||
context = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -152,5 +148,14 @@ namespace osu.Game.Database
|
|||||||
pending_writes.Value--;
|
pending_writes.Value--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void FlushConnections()
|
||||||
|
{
|
||||||
|
var previousContext = context;
|
||||||
|
context = null;
|
||||||
|
previousContext?.Dispose();
|
||||||
|
while (previousContext?.IsClosed == false)
|
||||||
|
Thread.Sleep(50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,6 +513,7 @@ namespace osu.Game
|
|||||||
public void Migrate(string path)
|
public void Migrate(string path)
|
||||||
{
|
{
|
||||||
contextFactory.FlushConnections();
|
contextFactory.FlushConnections();
|
||||||
|
realmFactory.FlushConnections();
|
||||||
(Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
|
(Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user