|
|
@ -9,8 +9,8 @@ namespace NzbDrone.Core.Datastore
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public interface IConnectionStringFactory
|
|
|
|
public interface IConnectionStringFactory
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string MainDbConnectionString { get; }
|
|
|
|
DatabaseConnectionInfo MainDbConnection { get; }
|
|
|
|
string LogDbConnectionString { get; }
|
|
|
|
DatabaseConnectionInfo LogDbConnection { get; }
|
|
|
|
string GetDatabasePath(string connectionString);
|
|
|
|
string GetDatabasePath(string connectionString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -22,15 +22,15 @@ namespace NzbDrone.Core.Datastore
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_configFileProvider = configFileProvider;
|
|
|
|
_configFileProvider = configFileProvider;
|
|
|
|
|
|
|
|
|
|
|
|
MainDbConnectionString = _configFileProvider.PostgresHost.IsNotNullOrWhiteSpace() ? GetPostgresConnectionString(_configFileProvider.PostgresMainDb) :
|
|
|
|
MainDbConnection = _configFileProvider.PostgresHost.IsNotNullOrWhiteSpace() ? GetPostgresConnectionString(_configFileProvider.PostgresMainDb) :
|
|
|
|
GetConnectionString(appFolderInfo.GetDatabase());
|
|
|
|
GetConnectionString(appFolderInfo.GetDatabase());
|
|
|
|
|
|
|
|
|
|
|
|
LogDbConnectionString = _configFileProvider.PostgresHost.IsNotNullOrWhiteSpace() ? GetPostgresConnectionString(_configFileProvider.PostgresLogDb) :
|
|
|
|
LogDbConnection = _configFileProvider.PostgresHost.IsNotNullOrWhiteSpace() ? GetPostgresConnectionString(_configFileProvider.PostgresLogDb) :
|
|
|
|
GetConnectionString(appFolderInfo.GetLogDatabase());
|
|
|
|
GetConnectionString(appFolderInfo.GetLogDatabase());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string MainDbConnectionString { get; private set; }
|
|
|
|
public DatabaseConnectionInfo MainDbConnection { get; private set; }
|
|
|
|
public string LogDbConnectionString { get; private set; }
|
|
|
|
public DatabaseConnectionInfo LogDbConnection { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string GetDatabasePath(string connectionString)
|
|
|
|
public string GetDatabasePath(string connectionString)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Datastore
|
|
|
|
return connectionBuilder.DataSource;
|
|
|
|
return connectionBuilder.DataSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static string GetConnectionString(string dbPath)
|
|
|
|
private static DatabaseConnectionInfo GetConnectionString(string dbPath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var connectionBuilder = new SQLiteConnectionStringBuilder
|
|
|
|
var connectionBuilder = new SQLiteConnectionStringBuilder
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -57,21 +57,22 @@ namespace NzbDrone.Core.Datastore
|
|
|
|
connectionBuilder.Add("Full FSync", true);
|
|
|
|
connectionBuilder.Add("Full FSync", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return connectionBuilder.ConnectionString;
|
|
|
|
return new DatabaseConnectionInfo(DatabaseType.SQLite, connectionBuilder.ConnectionString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetPostgresConnectionString(string dbName)
|
|
|
|
private DatabaseConnectionInfo GetPostgresConnectionString(string dbName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var connectionBuilder = new NpgsqlConnectionStringBuilder();
|
|
|
|
var connectionBuilder = new NpgsqlConnectionStringBuilder
|
|
|
|
|
|
|
|
{
|
|
|
|
connectionBuilder.Database = dbName;
|
|
|
|
Database = dbName,
|
|
|
|
connectionBuilder.Host = _configFileProvider.PostgresHost;
|
|
|
|
Host = _configFileProvider.PostgresHost,
|
|
|
|
connectionBuilder.Username = _configFileProvider.PostgresUser;
|
|
|
|
Username = _configFileProvider.PostgresUser,
|
|
|
|
connectionBuilder.Password = _configFileProvider.PostgresPassword;
|
|
|
|
Password = _configFileProvider.PostgresPassword,
|
|
|
|
connectionBuilder.Port = _configFileProvider.PostgresPort;
|
|
|
|
Port = _configFileProvider.PostgresPort,
|
|
|
|
connectionBuilder.Enlist = false;
|
|
|
|
Enlist = false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return connectionBuilder.ConnectionString;
|
|
|
|
return new DatabaseConnectionInfo(DatabaseType.PostgreSQL, connectionBuilder.ConnectionString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|