mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-13 09:43:12 +01:00
use individual connections
This commit is contained in:
@@ -19,11 +19,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// <summary>
|
||||
/// Connects to db.
|
||||
/// </summary>
|
||||
/// <param name="dbPath">The db path.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>Task{IDbConnection}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">dbPath</exception>
|
||||
public static async Task<IDbConnection> ConnectToDb(string dbPath, int? cacheSize, ILogger logger)
|
||||
public static async Task<IDbConnection> ConnectToDb(string dbPath, bool isReadOnly, bool enablePooling, int? cacheSize, ILogger logger)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dbPath))
|
||||
{
|
||||
@@ -38,7 +34,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
CacheSize = cacheSize ?? 2000,
|
||||
SyncMode = SynchronizationModes.Normal,
|
||||
DataSource = dbPath,
|
||||
JournalMode = SQLiteJournalModeEnum.Wal
|
||||
JournalMode = SQLiteJournalModeEnum.Wal,
|
||||
Pooling = enablePooling,
|
||||
ReadOnly = isReadOnly
|
||||
};
|
||||
|
||||
var connection = new SQLiteConnection(connectionstr.ConnectionString);
|
||||
@@ -47,15 +45,5 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static void BindFunction(this SQLiteConnection connection, SQLiteFunction function)
|
||||
{
|
||||
var attributes = function.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), true).Cast<SQLiteFunctionAttribute>().ToArray();
|
||||
if (attributes.Length == 0)
|
||||
{
|
||||
throw new InvalidOperationException("SQLiteFunction doesn't have SQLiteFunctionAttribute");
|
||||
}
|
||||
connection.BindFunction(attributes[0], function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user