diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-12 23:33:51 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-12 23:33:51 -0500 |
| commit | 95341c5c96059e4bd70f290ff05ae3abc9c49257 (patch) | |
| tree | 720dfca45628aea49a0a554afa40cfa062121cd5 /src/Emby.Server/Data | |
| parent | 3e06bda46b2569c1df47d9ab0c7a763dcf3b1451 (diff) | |
update .net core startup
Diffstat (limited to 'src/Emby.Server/Data')
| -rw-r--r-- | src/Emby.Server/Data/DbConnector.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Emby.Server/Data/DbConnector.cs b/src/Emby.Server/Data/DbConnector.cs new file mode 100644 index 000000000..bd70cff6c --- /dev/null +++ b/src/Emby.Server/Data/DbConnector.cs @@ -0,0 +1,52 @@ +using System; +using System.Data; +using System.Threading.Tasks; +using MediaBrowser.Model.Logging; +using Emby.Server.Core.Data; +using Microsoft.Data.Sqlite; + +namespace Emby.Server.Data +{ + public class DbConnector : IDbConnector + { + private readonly ILogger _logger; + + public DbConnector(ILogger logger) + { + _logger = logger; + } + + public async Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null) + { + if (string.IsNullOrEmpty(dbPath)) + { + throw new ArgumentNullException("dbPath"); + } + + //SQLiteConnection.SetMemoryStatus(false); + + var connectionstr = new SqliteConnectionStringBuilder + { + //PageSize = 4096, + //CacheSize = cacheSize ?? 2000, + //SyncMode = SynchronizationModes.Normal, + DataSource = dbPath, + //JournalMode = SQLiteJournalModeEnum.Wal, + + // This is causing crashing under linux + //Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT, + //ReadOnly = isReadOnly, + Cache = enablePooling ? SqliteCacheMode.Default : SqliteCacheMode.Private, + Mode = isReadOnly ? SqliteOpenMode.ReadOnly : SqliteOpenMode.ReadWriteCreate + }; + + var connectionString = connectionstr.ConnectionString; + + var connection = new SqliteConnection(connectionString); + + await connection.OpenAsync().ConfigureAwait(false); + + return connection; + } + } +}
\ No newline at end of file |
