mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
update sqlite
This commit is contained in:
@@ -27,11 +27,11 @@ namespace MediaBrowser.Server.Implementations.Activity
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "activitylog.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -78,9 +78,6 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite">
|
||||
<HintPath>..\ThirdParty\System.Data.SQLite.ManagedOnly\1.0.94.0\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net" />
|
||||
@@ -261,6 +258,8 @@
|
||||
<Compile Include="Notifications\IConfigurableNotificationService.cs" />
|
||||
<Compile Include="Persistence\BaseSqliteRepository.cs" />
|
||||
<Compile Include="Persistence\CleanDatabaseScheduledTask.cs" />
|
||||
<Compile Include="Persistence\DataExtensions.cs" />
|
||||
<Compile Include="Persistence\IDbConnector.cs" />
|
||||
<Compile Include="Persistence\MediaStreamColumns.cs" />
|
||||
<Compile Include="Social\SharingManager.cs" />
|
||||
<Compile Include="Social\SharingRepository.cs" />
|
||||
@@ -275,7 +274,6 @@
|
||||
<Compile Include="Notifications\InternalNotificationService.cs" />
|
||||
<Compile Include="Notifications\NotificationConfigurationFactory.cs" />
|
||||
<Compile Include="Notifications\NotificationManager.cs" />
|
||||
<Compile Include="Persistence\SqliteExtensions.cs" />
|
||||
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
||||
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
||||
<Compile Include="Persistence\SqliteProviderInfoRepository.cs" />
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace MediaBrowser.Server.Implementations.Notifications
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -3,16 +3,12 @@ using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SQLiteExtensions
|
||||
/// </summary>
|
||||
static class SqliteExtensions
|
||||
static class DataExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the specified conn is open.
|
||||
@@ -28,11 +24,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
return (IDataParameter)cmd.Parameters[index];
|
||||
}
|
||||
|
||||
|
||||
public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name, DbType type)
|
||||
{
|
||||
var param = cmd.CreateParameter();
|
||||
|
||||
|
||||
param.ParameterName = name;
|
||||
param.DbType = type;
|
||||
|
||||
@@ -48,11 +44,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
param.ParameterName = name;
|
||||
|
||||
paramCollection.Add(param);
|
||||
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stream from a DataReader at a given ordinal
|
||||
/// </summary>
|
||||
@@ -122,38 +118,6 @@ 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, ILogger logger)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dbPath))
|
||||
{
|
||||
throw new ArgumentNullException("dbPath");
|
||||
}
|
||||
|
||||
logger.Info("Sqlite {0} opening {1}", SQLiteConnection.SQLiteVersion, dbPath);
|
||||
|
||||
var connectionstr = new SQLiteConnectionStringBuilder
|
||||
{
|
||||
PageSize = 4096,
|
||||
CacheSize = 2000,
|
||||
SyncMode = SynchronizationModes.Full,
|
||||
DataSource = dbPath,
|
||||
JournalMode = SQLiteJournalModeEnum.Wal
|
||||
};
|
||||
|
||||
var connection = new SQLiteConnection(connectionstr.ConnectionString);
|
||||
|
||||
await connection.OpenAsync().ConfigureAwait(false);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static void Attach(IDbConnection db, string path, string alias)
|
||||
{
|
||||
using (var cmd = db.CreateCommand())
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
public interface IDbConnector
|
||||
{
|
||||
Task<IDbConnection> Connect(string dbPath);
|
||||
}
|
||||
}
|
||||
@@ -52,11 +52,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "fileorganization.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "refreshinfo.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "userdata_v2.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -43,12 +43,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "users.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
"create table if not exists users (guid GUID primary key, data BLOB)",
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace MediaBrowser.Server.Implementations.Security
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "authentication.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace MediaBrowser.Server.Implementations.Social
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "shares.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnector dbConnector)
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "sync14.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user