mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Add connection flushing support
This commit is contained in:
parent
36640f5dda
commit
6c350db097
@ -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
|
||||
{
|
||||
|
@ -160,5 +160,13 @@ namespace osu.Game.Database
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FlushConnections()
|
||||
{
|
||||
foreach (var context in threadContexts.Values)
|
||||
context.Dispose();
|
||||
|
||||
recycleThreadContexts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user