1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00

Add connection flushing support

This commit is contained in:
Dean Herbert 2020-05-11 21:37:07 +09:00
parent 36640f5dda
commit 6c350db097
3 changed files with 22 additions and 8 deletions

View File

@ -137,7 +137,7 @@ namespace osu.Game.Tests.NonVisual
Assert.That(storage.GetFullPath("."), Is.EqualTo(defaultStorageLocation));
(storage as OsuStorage)?.Migrate(customPath);
osu.Migrate(customPath);
Assert.That(storage.GetFullPath("."), Is.EqualTo(customPath));
@ -170,19 +170,18 @@ namespace osu.Game.Tests.NonVisual
try
{
var osu = loadOsu(host);
var storage = osu.Dependencies.Get<Storage>();
string customPath2 = $"{customPath}-2";
const string database_filename = "client.db";
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.DoesNotThrow(() => osu.Migrate(customPath));
Assert.That(File.Exists(Path.Combine(customPath, database_filename)));
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath2));
Assert.DoesNotThrow(() => osu.Migrate(customPath2));
Assert.That(File.Exists(Path.Combine(customPath2, database_filename)));
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.DoesNotThrow(() => osu.Migrate(customPath));
Assert.That(File.Exists(Path.Combine(customPath, database_filename)));
}
finally
@ -200,10 +199,9 @@ namespace osu.Game.Tests.NonVisual
try
{
var osu = loadOsu(host);
var storage = osu.Dependencies.Get<Storage>();
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.Throws<InvalidOperationException>(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.DoesNotThrow(() => osu.Migrate(customPath));
Assert.Throws<InvalidOperationException>(() => osu.Migrate(customPath));
}
finally
{

View File

@ -160,5 +160,13 @@ namespace osu.Game.Database
}
}
}
public void FlushConnections()
{
foreach (var context in threadContexts.Values)
context.Dispose();
recycleThreadContexts();
}
}
}

View File

@ -328,6 +328,8 @@ namespace osu.Game
{
base.Dispose(isDisposing);
RulesetStore?.Dispose();
ContextFactory.FlushConnections();
}
private class OsuUserInputManager : UserInputManager
@ -355,5 +357,11 @@ namespace osu.Game
public override bool ChangeFocusOnClick => false;
}
}
public void Migrate(string path)
{
ContextFactory.FlushConnections();
(Storage as OsuStorage)?.Migrate(path);
}
}
}