Move database connection string operations local

In line with framework changes in
https://github.com/ppy/osu-framework/pull/4793.
This commit is contained in:
Dean Herbert
2021-09-27 17:32:40 +09:00
parent 7f45bd27f2
commit d4310f5d9a
3 changed files with 7 additions and 9 deletions

View File

@ -13,7 +13,7 @@ namespace osu.Game.Database
{
private readonly Storage storage;
private const string database_name = @"client";
private const string database_name = @"client.db";
private ThreadLocal<OsuDbContext> threadContexts;
@ -139,7 +139,7 @@ namespace osu.Game.Database
threadContexts = new ThreadLocal<OsuDbContext>(CreateContext, true);
}
protected virtual OsuDbContext CreateContext() => new OsuDbContext(storage.GetDatabaseConnectionString(database_name))
protected virtual OsuDbContext CreateContext() => new OsuDbContext(CreateDatabaseConnectionString(database_name, storage))
{
Database = { AutoTransactionsEnabled = false }
};
@ -152,7 +152,7 @@ namespace osu.Game.Database
try
{
storage.DeleteDatabase(database_name);
storage.Delete(database_name);
}
catch
{
@ -171,5 +171,7 @@ namespace osu.Game.Database
recycleThreadContexts();
}
public static string CreateDatabaseConnectionString(string filename, Storage storage) => string.Concat("Data Source=", storage.GetFullPath($@"{filename}", true));
}
}