mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Remove SingletonContextFactory
It is dangerous to use this as it doesn't correctly handle contexts and can cause issues that will never actually arise in normal execution. # Conflicts: # osu.Game/Database/SingletonContextFactory.cs
This commit is contained in:
@ -11,7 +11,7 @@ namespace osu.Game.Database
|
||||
{
|
||||
public class DatabaseContextFactory : IDatabaseContextFactory
|
||||
{
|
||||
private readonly GameHost host;
|
||||
private readonly Storage storage;
|
||||
|
||||
private const string database_name = @"client";
|
||||
|
||||
@ -26,9 +26,9 @@ namespace osu.Game.Database
|
||||
|
||||
private IDbContextTransaction currentWriteTransaction;
|
||||
|
||||
public DatabaseContextFactory(GameHost host)
|
||||
public DatabaseContextFactory(Storage storage)
|
||||
{
|
||||
this.host = host;
|
||||
this.storage = storage;
|
||||
recycleThreadContexts();
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ namespace osu.Game.Database
|
||||
|
||||
private void recycleThreadContexts() => threadContexts = new ThreadLocal<OsuDbContext>(CreateContext);
|
||||
|
||||
protected virtual OsuDbContext CreateContext() => new OsuDbContext(host.Storage.GetDatabaseConnectionString(database_name))
|
||||
protected virtual OsuDbContext CreateContext() => new OsuDbContext(storage.GetDatabaseConnectionString(database_name))
|
||||
{
|
||||
Database = { AutoTransactionsEnabled = false }
|
||||
};
|
||||
@ -129,7 +129,7 @@ namespace osu.Game.Database
|
||||
recycleThreadContexts();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
host.Storage.DeleteDatabase(database_name);
|
||||
storage.DeleteDatabase(database_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user