mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 19:23:38 +01:00
update sqlite
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using MediaBrowser.Controller.Power;
|
||||
using MediaBrowser.Server.Implementations.Persistence;
|
||||
using MediaBrowser.Server.Startup.Common.FFMpeg;
|
||||
using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;
|
||||
|
||||
@@ -17,9 +18,12 @@ namespace MediaBrowser.Server.Mono.Native
|
||||
public abstract class BaseMonoApp : INativeApp
|
||||
{
|
||||
protected StartupOptions StartupOptions { get; private set; }
|
||||
protected BaseMonoApp(StartupOptions startupOptions)
|
||||
protected ILogger Logger { get; private set; }
|
||||
|
||||
protected BaseMonoApp(StartupOptions startupOptions, ILogger logger)
|
||||
{
|
||||
StartupOptions = startupOptions;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -227,6 +231,11 @@ namespace MediaBrowser.Server.Mono.Native
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDbConnector GetDbConnector()
|
||||
{
|
||||
return new DbConnector(Logger);
|
||||
}
|
||||
|
||||
public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
|
||||
{
|
||||
var info = new FFMpegInstallInfo();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Server.Startup.Common;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Server.Startup.Common;
|
||||
|
||||
namespace MediaBrowser.Server.Mono.Native
|
||||
{
|
||||
@@ -7,8 +8,8 @@ namespace MediaBrowser.Server.Mono.Native
|
||||
/// </summary>
|
||||
internal class NativeApp : BaseMonoApp
|
||||
{
|
||||
public NativeApp(StartupOptions startupOptions)
|
||||
: base(startupOptions)
|
||||
public NativeApp(StartupOptions startupOptions, ILogger logger)
|
||||
: base(startupOptions, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
62
MediaBrowser.Server.Mono/Native/SqliteExtensions.cs
Normal file
62
MediaBrowser.Server.Mono/Native/SqliteExtensions.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Server.Implementations.Persistence;
|
||||
|
||||
namespace MediaBrowser.Server.Mono.Native
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SQLiteExtensions
|
||||
/// </summary>
|
||||
static class SqliteExtensions
|
||||
{
|
||||
/// <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 class DbConnector : IDbConnector
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DbConnector(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task<IDbConnection> Connect(string dbPath)
|
||||
{
|
||||
return SqliteExtensions.ConnectToDb(dbPath, _logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user