2013-07-05 06:56:27 +03:00
|
|
|
using System;
|
|
|
|
using System.Data.SQLite;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore
|
|
|
|
{
|
|
|
|
public interface IConnectionStringFactory
|
|
|
|
{
|
|
|
|
string MainDbConnectionString { get; }
|
|
|
|
string LogDbConnectionString { get; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ConnectionStringFactory : IConnectionStringFactory
|
|
|
|
{
|
2013-07-05 07:43:28 +03:00
|
|
|
public ConnectionStringFactory(IAppFolderInfo appFolderInfo)
|
2013-07-05 06:56:27 +03:00
|
|
|
{
|
2013-07-05 07:43:28 +03:00
|
|
|
MainDbConnectionString = GetConnectionString(appFolderInfo.GetNzbDroneDatabase());
|
|
|
|
LogDbConnectionString = GetConnectionString(appFolderInfo.GetLogDatabase());
|
2013-07-05 06:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public string MainDbConnectionString { get; private set; }
|
|
|
|
public string LogDbConnectionString { get; private set; }
|
|
|
|
|
|
|
|
private static string GetConnectionString(string dbPath)
|
|
|
|
{
|
|
|
|
var connectionBuilder = new SQLiteConnectionStringBuilder();
|
|
|
|
|
|
|
|
connectionBuilder.DataSource = dbPath;
|
|
|
|
connectionBuilder.CacheSize = (int)-10.Megabytes();
|
|
|
|
connectionBuilder.DateTimeKind = DateTimeKind.Utc;
|
|
|
|
connectionBuilder.JournalMode = SQLiteJournalModeEnum.Wal;
|
|
|
|
|
|
|
|
return connectionBuilder.ConnectionString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|