mirror of https://github.com/lidarr/Lidarr
Merge branch 'master' of git://github.com/kayone/NzbDrone
This commit is contained in:
commit
43e5cb7b31
|
@ -125,7 +125,7 @@
|
||||||
<virtualDirectory path="/" physicalPath="%NZBDRONE_PATH%\NZBDrone.Web" />
|
<virtualDirectory path="/" physicalPath="%NZBDRONE_PATH%\NZBDrone.Web" />
|
||||||
</application>
|
</application>
|
||||||
<bindings>
|
<bindings>
|
||||||
<binding protocol="http" bindingInformation="*:8980:" />
|
<binding protocol="http" bindingInformation="*:8989:" />
|
||||||
</bindings>
|
</bindings>
|
||||||
</site>
|
</site>
|
||||||
<applicationDefaults applicationPool="IISExpressAppPool" />
|
<applicationDefaults applicationPool="IISExpressAppPool" />
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace NzbDrone.Core.Test
|
||||||
[TestCase(@"D:\shares\TV Shows\Parks And Recreation\Season 2\S02E21 - 94 Meetings - 720p TV.mkv", 2, 21)]
|
[TestCase(@"D:\shares\TV Shows\Parks And Recreation\Season 2\S02E21 - 94 Meetings - 720p TV.mkv", 2, 21)]
|
||||||
[TestCase(@"D:\shares\TV Shows\Battlestar Galactica (2003)\Season 2\S02E21.avi", 2, 21)]
|
[TestCase(@"D:\shares\TV Shows\Battlestar Galactica (2003)\Season 2\S02E21.avi", 2, 21)]
|
||||||
[TestCase("C:/Test/TV/Chuck.4x05.HDTV.XviD-LOL", 4, 5)]
|
[TestCase("C:/Test/TV/Chuck.4x05.HDTV.XviD-LOL", 4, 5)]
|
||||||
|
[TestCase(@"P:\TV Shows\House\Season 6\S06E13 - 5 to 9 - 720p BluRay.mkv", 6, 13)]
|
||||||
public void PathParse_tests(string path, int season, int episode)
|
public void PathParse_tests(string path, int season, int episode)
|
||||||
{
|
{
|
||||||
var result = Parser.ParsePath(path);
|
var result = Parser.ParsePath(path);
|
||||||
|
|
|
@ -45,19 +45,17 @@ namespace NzbDrone.Core.Datastore
|
||||||
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
||||||
{
|
{
|
||||||
MigrationsHelper.Run(connectionString, true);
|
MigrationsHelper.Run(connectionString, true);
|
||||||
var sqliteConnection = new SqlCeConnection(connectionString);
|
|
||||||
DbConnection connection = sqliteConnection;
|
|
||||||
|
|
||||||
if (profiled)
|
var factory = new PetaDbProviderFactory
|
||||||
{
|
{
|
||||||
connection = ProfiledDbConnection.Get(sqliteConnection);
|
IsProfiled = profiled
|
||||||
}
|
};
|
||||||
|
|
||||||
var db = new Database(connection, Database.DBType.SqlServerCE);
|
var db = new Database(connectionString, factory, Database.DBType.SqlServerCE)
|
||||||
db.ForceDateTimesToUtc = false;
|
{
|
||||||
|
KeepConnectionAlive = true,
|
||||||
if (connection.State != ConnectionState.Open)
|
ForceDateTimesToUtc = false,
|
||||||
connection.Open();
|
};
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Common;
|
||||||
|
using System.Data.SqlServerCe;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using MvcMiniProfiler.Data;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore
|
||||||
|
{
|
||||||
|
class PetaDbProviderFactory : DbProviderFactory
|
||||||
|
{
|
||||||
|
public Boolean IsProfiled { get; set; }
|
||||||
|
|
||||||
|
public override DbConnection CreateConnection()
|
||||||
|
{
|
||||||
|
var sqliteConnection = new SqlCeConnection();
|
||||||
|
DbConnection connection = sqliteConnection;
|
||||||
|
|
||||||
|
if (IsProfiled)
|
||||||
|
{
|
||||||
|
connection = ProfiledDbConnection.Get(sqliteConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -282,7 +282,7 @@ namespace PetaPoco
|
||||||
{
|
{
|
||||||
_sharedConnection = connection;
|
_sharedConnection = connection;
|
||||||
_connectionString = connection.ConnectionString;
|
_connectionString = connection.ConnectionString;
|
||||||
_sharedConnectionDepth = 2; // Prevent closing external connection
|
|
||||||
_dbType = dbType;
|
_dbType = dbType;
|
||||||
CommonConstruct();
|
CommonConstruct();
|
||||||
}
|
}
|
||||||
|
@ -294,10 +294,11 @@ namespace PetaPoco
|
||||||
CommonConstruct();
|
CommonConstruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Database(string connectionString, DbProviderFactory provider)
|
public Database(string connectionString, DbProviderFactory provider, DBType dbType)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
_factory = provider;
|
_factory = provider;
|
||||||
|
_dbType = dbType;
|
||||||
CommonConstruct();
|
CommonConstruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,6 +376,7 @@ namespace PetaPoco
|
||||||
{
|
{
|
||||||
// Automatically close one open connection reference
|
// Automatically close one open connection reference
|
||||||
// (Works with KeepConnectionAlive and manually opening a shared connection)
|
// (Works with KeepConnectionAlive and manually opening a shared connection)
|
||||||
|
KeepConnectionAlive = false;
|
||||||
CloseSharedConnection();
|
CloseSharedConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,18 +386,14 @@ namespace PetaPoco
|
||||||
// Open a connection (can be nested)
|
// Open a connection (can be nested)
|
||||||
public void OpenSharedConnection()
|
public void OpenSharedConnection()
|
||||||
{
|
{
|
||||||
if (_sharedConnectionDepth == 0)
|
if (_sharedConnection == null || _sharedConnection.State == ConnectionState.Closed || _sharedConnection.State == ConnectionState.Broken)
|
||||||
{
|
{
|
||||||
_sharedConnection = _factory.CreateConnection();
|
_sharedConnection = _factory.CreateConnection();
|
||||||
_sharedConnection.ConnectionString = _connectionString;
|
_sharedConnection.ConnectionString = _connectionString;
|
||||||
_sharedConnection.Open();
|
_sharedConnection.Open();
|
||||||
|
|
||||||
_sharedConnection = OnConnectionOpened(_sharedConnection);
|
_sharedConnection = OnConnectionOpened(_sharedConnection);
|
||||||
|
|
||||||
if (KeepConnectionAlive)
|
|
||||||
_sharedConnectionDepth++; // Make sure you call Dispose
|
|
||||||
}
|
}
|
||||||
_sharedConnectionDepth++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -404,17 +402,13 @@ namespace PetaPoco
|
||||||
// Close a previously opened connection
|
// Close a previously opened connection
|
||||||
public void CloseSharedConnection()
|
public void CloseSharedConnection()
|
||||||
{
|
{
|
||||||
if (_sharedConnectionDepth > 0)
|
if (!KeepConnectionAlive && _sharedConnection != null)
|
||||||
{
|
|
||||||
_sharedConnectionDepth--;
|
|
||||||
if (_sharedConnectionDepth == 0)
|
|
||||||
{
|
{
|
||||||
OnConnectionClosing(_sharedConnection);
|
OnConnectionClosing(_sharedConnection);
|
||||||
_sharedConnection.Dispose();
|
_sharedConnection.Dispose();
|
||||||
_sharedConnection = null;
|
_sharedConnection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Access to our shared connection
|
// Access to our shared connection
|
||||||
public IDbConnection Connection
|
public IDbConnection Connection
|
||||||
|
@ -2530,7 +2524,6 @@ namespace PetaPoco
|
||||||
DbProviderFactory _factory;
|
DbProviderFactory _factory;
|
||||||
IDbConnection _sharedConnection;
|
IDbConnection _sharedConnection;
|
||||||
IDbTransaction _transaction;
|
IDbTransaction _transaction;
|
||||||
int _sharedConnectionDepth;
|
|
||||||
int _transactionDepth;
|
int _transactionDepth;
|
||||||
bool _transactionCancelled;
|
bool _transactionCancelled;
|
||||||
string _lastSql;
|
string _lastSql;
|
||||||
|
|
|
@ -178,6 +178,7 @@
|
||||||
<Compile Include="Datastore\CustomeMapper.cs" />
|
<Compile Include="Datastore\CustomeMapper.cs" />
|
||||||
<Compile Include="Datastore\Migrations\Migration20110726.cs" />
|
<Compile Include="Datastore\Migrations\Migration20110726.cs" />
|
||||||
<Compile Include="Datastore\Migrations\Migration20110707.cs" />
|
<Compile Include="Datastore\Migrations\Migration20110707.cs" />
|
||||||
|
<Compile Include="Datastore\PetaDbProviderFactory.cs" />
|
||||||
<Compile Include="Fluent.cs" />
|
<Compile Include="Fluent.cs" />
|
||||||
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
||||||
<Compile Include="Helpers\FileSizeFormatHelpercs.cs" />
|
<Compile Include="Helpers\FileSizeFormatHelpercs.cs" />
|
||||||
|
|
Loading…
Reference in New Issue