Alot of refactoring.
This commit is contained in:
parent
2e94e322f4
commit
72d0fc50ed
|
@ -1,59 +0,0 @@
|
|||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ConfigProviderTest
|
||||
{
|
||||
|
||||
private ConfigProvider GetConfigProvider()
|
||||
{
|
||||
var envMoq = new Mock<EnviromentProvider>();
|
||||
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
||||
|
||||
return new ConfigProvider(envMoq.Object);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void IISExpress_path_test()
|
||||
{
|
||||
GetConfigProvider().IISDirectory.Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetConfigProvider().AppDataDirectory.Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Config_path_test()
|
||||
{
|
||||
GetConfigProvider().ConfigFile.Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\Config.xml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISConfig_path_test()
|
||||
{
|
||||
GetConfigProvider().IISConfigPath.Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISExe_path_test()
|
||||
{
|
||||
GetConfigProvider().IISExePath.Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NlogConfig_path_test()
|
||||
{
|
||||
GetConfigProvider().NlogConfigPath.Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\log.config");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AutoMoq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class IISProviderTest
|
||||
{
|
||||
[Test]
|
||||
public void start_should_set_IISProccessId_property()
|
||||
{
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
var configMock = mocker.GetMock<ConfigProvider>();
|
||||
configMock.SetupGet(c => c.IISExePath).Returns("NzbDrone.Test.Dummy.exe");
|
||||
|
||||
mocker.Resolve<ProcessProvider>();
|
||||
|
||||
var iisProvider = mocker.Resolve<IISProvider>();
|
||||
|
||||
iisProvider.StartServer();
|
||||
|
||||
iisProvider.IISProcessId.Should().NotBe(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -68,8 +68,6 @@
|
|||
<Compile Include="Fixtures.cs" />
|
||||
<Compile Include="RouterTest.cs" />
|
||||
<Compile Include="MonitoringProviderTest.cs" />
|
||||
<Compile Include="ConfigProviderTest.cs" />
|
||||
<Compile Include="IISProviderTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -3,9 +3,9 @@ using AutoMoq;
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -16,10 +16,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
WithTempAsStartUpPath();
|
||||
WithTempAsAppPath();
|
||||
|
||||
//Reset config file
|
||||
var configFile = Mocker.Resolve<PathProvider>().AppConfigFile;
|
||||
var configFile = Mocker.Resolve<EnviromentProvider>().GetConfigPath();
|
||||
|
||||
if (File.Exists(configFile))
|
||||
File.Delete(configFile);
|
|
@ -61,6 +61,8 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigFileProviderTest.cs" />
|
||||
<Compile Include="PathExtentionFixture.cs" />
|
||||
<Compile Include="DiskProviderTests.cs" />
|
||||
<Compile Include="EnviromentProviderTest.cs" />
|
||||
<Compile Include="Fixtures.cs" />
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathExtentionFixture
|
||||
{
|
||||
|
||||
private EnviromentProvider GetEnviromentProvider()
|
||||
{
|
||||
var envMoq = new Mock<EnviromentProvider>();
|
||||
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
||||
|
||||
return envMoq.Object;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Config_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISConfig_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetIISConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISExe_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetIISExe().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NlogConfig_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetNlogConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\log.config");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,132 +4,45 @@ using System.Linq;
|
|||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Common.Model;
|
||||
|
||||
namespace NzbDrone.Providers
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public class ConfigProvider
|
||||
public class ConfigFileProvider
|
||||
{
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private static readonly Logger Logger = LogManager.GetLogger("Host.ConfigProvider");
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public ConfigProvider(EnviromentProvider enviromentProvider)
|
||||
|
||||
|
||||
private readonly string _configFile;
|
||||
public ConfigFileProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_configFile = _enviromentProvider.GetConfigPath();
|
||||
}
|
||||
|
||||
public ConfigProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual int PortNumber
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetValueInt("Port", 8989); }
|
||||
set { SetValue("Port", value); }
|
||||
}
|
||||
|
||||
public virtual bool LaunchBrowser
|
||||
{
|
||||
get { return GetValueBoolean("LaunchBrowser", true); }
|
||||
}
|
||||
|
||||
public virtual string IISDirectory
|
||||
{
|
||||
get { return Path.Combine(_enviromentProvider.ApplicationPath, "IISExpress"); }
|
||||
}
|
||||
|
||||
public virtual string IISExePath
|
||||
{
|
||||
get { return Path.Combine(IISDirectory, "iisexpress.exe"); }
|
||||
}
|
||||
|
||||
public virtual string IISConfigPath
|
||||
{
|
||||
get { return Path.Combine(IISDirectory, "AppServer", "applicationhost.config"); }
|
||||
}
|
||||
|
||||
public virtual string AppDataDirectory
|
||||
{
|
||||
get { return Path.Combine(_enviromentProvider.ApplicationPath, "NzbDrone.Web", "App_Data"); }
|
||||
}
|
||||
|
||||
public virtual string ConfigFile
|
||||
{
|
||||
get { return Path.Combine(AppDataDirectory, "Config.xml"); }
|
||||
}
|
||||
|
||||
public virtual string NlogConfigPath
|
||||
{
|
||||
get { return Path.Combine(_enviromentProvider.ApplicationPath, "NzbDrone.Web\\log.config"); }
|
||||
set { SetValue("LaunchBrowser", value); }
|
||||
}
|
||||
|
||||
public virtual AuthenticationType AuthenticationType
|
||||
{
|
||||
get { return (AuthenticationType)GetValueInt("AuthenticationType", 0); }
|
||||
set { SetValue("AuthenticationType", (int)value); }
|
||||
}
|
||||
|
||||
public virtual void UpdateIISConfig(string configPath)
|
||||
public virtual string GetValue(string key, object defaultValue, string parent = null)
|
||||
{
|
||||
Logger.Info(@"Server configuration file: {0}", configPath);
|
||||
Logger.Info(@"Configuring server to: [http://localhost:{0}]", PortNumber);
|
||||
|
||||
var configXml = XDocument.Load(configPath);
|
||||
|
||||
var bindings =
|
||||
configXml.XPathSelectElement("configuration/system.applicationHost/sites").Elements("site").Where(
|
||||
d => d.Attribute("name").Value.ToLowerInvariant() == "nzbdrone").First().Element("bindings");
|
||||
bindings.Descendants().Remove();
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:localhost", PortNumber))
|
||||
));
|
||||
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", PortNumber))
|
||||
));
|
||||
|
||||
//Update the authenticationTypes
|
||||
|
||||
var location = configXml.XPathSelectElement("configuration").Elements("location").Where(
|
||||
d => d.Attribute("path").Value.ToLowerInvariant() == "nzbdrone").First();
|
||||
|
||||
|
||||
var authenticationTypes = location.XPathSelectElements("system.webServer/security/authentication").First().Descendants();
|
||||
|
||||
//Set all authentication types enabled to false
|
||||
foreach (var child in authenticationTypes)
|
||||
{
|
||||
child.Attribute("enabled").Value = "false";
|
||||
}
|
||||
|
||||
var configuredAuthType = String.Format("{0}Authentication", AuthenticationType.ToString()).ToLowerInvariant();
|
||||
|
||||
//Set the users authenticationType to true
|
||||
authenticationTypes.Where(t => t.Name.ToString().ToLowerInvariant() == configuredAuthType).Single().Attribute("enabled").Value = "true";
|
||||
|
||||
configXml.Save(configPath);
|
||||
}
|
||||
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
//Create the config file here
|
||||
Directory.CreateDirectory(AppDataDirectory);
|
||||
|
||||
if (!File.Exists(ConfigFile))
|
||||
{
|
||||
WriteDefaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetValue(string key, object defaultValue, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(ConfigFile);
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
@ -142,7 +55,7 @@ namespace NzbDrone.Providers
|
|||
SetValue(key, defaultValue, parent);
|
||||
|
||||
//Reload the configFile
|
||||
xDoc = XDocument.Load(ConfigFile);
|
||||
xDoc = XDocument.Load(_configFile);
|
||||
config = xDoc.Descendants("Config").Single();
|
||||
}
|
||||
|
||||
|
@ -173,7 +86,7 @@ namespace NzbDrone.Providers
|
|||
|
||||
public virtual void SetValue(string key, object value, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(ConfigFile);
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
@ -197,16 +110,66 @@ namespace NzbDrone.Providers
|
|||
else
|
||||
parentContainer.Descendants(key).Single().Value = value.ToString();
|
||||
|
||||
xDoc.Save(ConfigFile);
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
|
||||
public virtual void WriteDefaultConfig()
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
if (!File.Exists(_configFile))
|
||||
{
|
||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||
|
||||
xDoc.Add(new XElement("Config"));
|
||||
|
||||
xDoc.Save(ConfigFile);
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual void UpdateIISConfig(string configPath)
|
||||
{
|
||||
logger.Info(@"Server configuration file: {0}", configPath);
|
||||
logger.Info(@"Configuring server to: [http://localhost:{0}]", Port);
|
||||
|
||||
var configXml = XDocument.Load(configPath);
|
||||
|
||||
var bindings =
|
||||
configXml.XPathSelectElement("configuration/system.applicationHost/sites").Elements("site").Where(
|
||||
d => d.Attribute("name").Value.ToLowerInvariant() == "nzbdrone").First().Element("bindings");
|
||||
bindings.Descendants().Remove();
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:localhost", Port))
|
||||
));
|
||||
|
||||
bindings.Add(
|
||||
new XElement("binding",
|
||||
new XAttribute("protocol", "http"),
|
||||
new XAttribute("bindingInformation", String.Format("*:{0}:", Port))
|
||||
));
|
||||
|
||||
//Update the authenticationTypes
|
||||
|
||||
var location = configXml.XPathSelectElement("configuration").Elements("location").Where(
|
||||
d => d.Attribute("path").Value.ToLowerInvariant() == "nzbdrone").First();
|
||||
|
||||
|
||||
var authenticationTypes = location.XPathSelectElements("system.webServer/security/authentication").First().Descendants();
|
||||
|
||||
//Set all authentication types enabled to false
|
||||
foreach (var child in authenticationTypes)
|
||||
{
|
||||
child.Attribute("enabled").Value = "false";
|
||||
}
|
||||
|
||||
var configuredAuthType = String.Format("{0}Authentication", AuthenticationType.ToString()).ToLowerInvariant();
|
||||
|
||||
//Set the users authenticationType to true
|
||||
authenticationTypes.Where(t => t.Name.ToString().ToLowerInvariant() == configuredAuthType).Single().Attribute("enabled").Value = "true";
|
||||
|
||||
configXml.Save(configPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -72,6 +72,14 @@ namespace NzbDrone.Common
|
|||
}
|
||||
}
|
||||
|
||||
public virtual String SystemTemp
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Version Version
|
||||
{
|
||||
get { return Assembly.GetExecutingAssembly().GetName().Version; }
|
||||
|
|
|
@ -33,7 +33,6 @@ namespace NzbDrone.Common
|
|||
consoleTarget.Layout = "${message} ${exception}";
|
||||
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule(loggerNamePattern, minLevel, consoleTarget));
|
||||
Reload();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -57,7 +56,6 @@ namespace NzbDrone.Common
|
|||
udpTarget.IncludeNdc = true;
|
||||
LogManager.Configuration.AddTarget(udpTarget.GetType().Name, udpTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, udpTarget));
|
||||
Reload();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -70,19 +68,21 @@ namespace NzbDrone.Common
|
|||
}
|
||||
|
||||
public static void RegisterExceptioneer()
|
||||
{
|
||||
if (EnviromentProvider.IsProduction)
|
||||
{
|
||||
try
|
||||
{
|
||||
var exTarget = new ExceptioneerTarget();
|
||||
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, exTarget));
|
||||
Reload();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Reload()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Common.Model
|
||||
{
|
||||
public enum AuthenticationType
|
||||
{
|
||||
Anonymous = 0,
|
||||
Windows = 1
|
||||
}
|
||||
}
|
|
@ -42,11 +42,14 @@
|
|||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigFileProvider.cs" />
|
||||
<Compile Include="ConsoleProvider.cs" />
|
||||
<Compile Include="Model\AuthenticationType.cs" />
|
||||
<Compile Include="PathExtentions.cs" />
|
||||
<Compile Include="PathProvider.cs" />
|
||||
<Compile Include="DiskProvider.cs" />
|
||||
<Compile Include="EnviromentProvider.cs" />
|
||||
<Compile Include="ExceptioneerTarget.cs" />
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
|
@ -9,6 +6,8 @@ namespace NzbDrone.Common
|
|||
{
|
||||
private const string WEB_FOLDER = "NzbDrone.Web\\";
|
||||
private const string APP_DATA = "App_Data\\";
|
||||
public const string IIS_FOLDER = EnviromentProvider.IIS_FOLDER_NAME;
|
||||
public const string IIS_EXE = "iisexpress.exe";
|
||||
|
||||
|
||||
private const string LOG_CONFIG_FILE = "log.config";
|
||||
|
@ -21,19 +20,74 @@ namespace NzbDrone.Common
|
|||
private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\";
|
||||
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
|
||||
|
||||
public static string GetUpdateSandboxFolder(this PathProvider pathProvider)
|
||||
public static string GetUpdateSandboxFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(pathProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME);
|
||||
return Path.Combine(enviromentProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME);
|
||||
}
|
||||
|
||||
public static string GetUpdateBackUpFolder(this PathProvider pathProvider)
|
||||
public static string GetUpdateBackUpFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(pathProvider.GetUpdateSandboxFolder(), UPDATE_BACKUP_FOLDER_NAME);
|
||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_BACKUP_FOLDER_NAME);
|
||||
}
|
||||
|
||||
public static string GetUpdatePackageFolder(this PathProvider pathProvider)
|
||||
public static string GetUpdatePackageFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(pathProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME);
|
||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME);
|
||||
}
|
||||
|
||||
public static string GetIISFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.ApplicationPath, IIS_FOLDER);
|
||||
}
|
||||
|
||||
public static string GetIISExe(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetIISFolder(), IIS_EXE);
|
||||
}
|
||||
|
||||
public static string GetIISConfigPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetIISFolder(), "AppServer", "applicationhost.config");
|
||||
}
|
||||
|
||||
public static string GetWebRoot(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.ApplicationPath, WEB_FOLDER);
|
||||
}
|
||||
|
||||
public static string GetAppDataPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), APP_DATA);
|
||||
}
|
||||
|
||||
public static string GetNlogConfigPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), LOG_CONFIG_FILE);
|
||||
}
|
||||
|
||||
public static string GetConfigPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.ApplicationPath, APP_CONFIG_FILE);
|
||||
}
|
||||
|
||||
public static string GetNzbDronoeDbFile(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetAppDataPath(), NZBDRONE_DB_FILE);
|
||||
}
|
||||
|
||||
public static string GetLogDbFileDbFile(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetAppDataPath(), LOG_DB_FILE);
|
||||
}
|
||||
|
||||
public static string GetBannerPath(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), "Content", "Images", "Banners");
|
||||
}
|
||||
|
||||
public static string GetCacheFolder(this EnviromentProvider enviromentProvider)
|
||||
{
|
||||
return Path.Combine(enviromentProvider.GetWebRoot(), "Cache");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public class PathProvider
|
||||
{
|
||||
|
||||
private const string WEB_FOLDER = "NzbDrone.Web";
|
||||
private const string APP_DATA = "App_Data";
|
||||
|
||||
private const string LOG_CONFIG_FILE = "log.config";
|
||||
private const string APP_CONFIG_FILE = "config.xml";
|
||||
|
||||
private const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
|
||||
private const string LOG_DB_FILE = "log.sdf";
|
||||
|
||||
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update";
|
||||
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup";
|
||||
|
||||
private readonly string _applicationPath;
|
||||
|
||||
|
||||
public PathProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_applicationPath = enviromentProvider.ApplicationPath;
|
||||
}
|
||||
|
||||
public PathProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual String LogPath
|
||||
{
|
||||
get { return Environment.CurrentDirectory; }
|
||||
}
|
||||
|
||||
public virtual string WebRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(_applicationPath, WEB_FOLDER);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string AppData
|
||||
{
|
||||
get
|
||||
{
|
||||
var path = Path.Combine(WebRoot, APP_DATA);
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string NzbDronoeDbFile
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return Path.Combine(AppData, NZBDRONE_DB_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string LogDbFile
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return Path.Combine(AppData, LOG_DB_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual String SystemTemp
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
|
||||
public string LogConfigFile
|
||||
{
|
||||
get { return Path.Combine(WebRoot, LOG_CONFIG_FILE); }
|
||||
}
|
||||
|
||||
public string AppConfigFile
|
||||
{
|
||||
get { return Path.Combine(_applicationPath, APP_CONFIG_FILE); }
|
||||
}
|
||||
|
||||
public string BannerPath
|
||||
{
|
||||
get { return Path.Combine(WebRoot, "Content", "Images", "Banners"); }
|
||||
}
|
||||
|
||||
public string CacheFolder
|
||||
{
|
||||
get { return Path.Combine(AppData, "Cache"); }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NLog;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
|
@ -13,7 +14,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
class CentralDispatchFixture : TestBase
|
||||
class CentralDispatchFixture : CoreTest
|
||||
{
|
||||
readonly IList<Type> indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).ToList();
|
||||
readonly IList<Type> jobs = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).ToList();
|
||||
|
@ -99,5 +100,12 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
first.Should().BeSameAs(second);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDownBase()
|
||||
{
|
||||
WebTimer.Stop();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeStatusTest : TestBase
|
||||
public class EpisodeStatusTest : CoreTest
|
||||
{
|
||||
[TestCase(1, false, false, EpisodeStatusType.NotAired)]
|
||||
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class FluentTest : TestBase
|
||||
public class FluentTest : CoreTest
|
||||
{
|
||||
[TestCase(null, "def", "def")]
|
||||
[TestCase("", "def", "def")]
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Test.Common;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public class CoreTest : TestBase
|
||||
// ReSharper disable InconsistentNaming
|
||||
{
|
||||
static CoreTest()
|
||||
{
|
||||
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
||||
foreach (var file in oldDbFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
MockLib.CreateDataBaseTemplate();
|
||||
}
|
||||
|
||||
protected StandardKernel LiveKernel = null;
|
||||
protected IDatabase Db = null;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetupBase()
|
||||
{
|
||||
LiveKernel = new StandardKernel();
|
||||
}
|
||||
|
||||
protected override void WithStrictMocker()
|
||||
{
|
||||
base.WithStrictMocker();
|
||||
|
||||
if (Db != null)
|
||||
{
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
}
|
||||
|
||||
protected void WithRealDb()
|
||||
{
|
||||
Db = MockLib.GetEmptyDatabase();
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
using System.IO;
|
||||
using AutoMoq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public class TestBase : LoggingTest
|
||||
// ReSharper disable InconsistentNaming
|
||||
{
|
||||
static TestBase()
|
||||
{
|
||||
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
||||
foreach (var file in oldDbFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
MockLib.CreateDataBaseTemplate();
|
||||
}
|
||||
|
||||
protected StandardKernel LiveKernel = null;
|
||||
protected AutoMoqer Mocker = null;
|
||||
protected IDatabase Db = null;
|
||||
|
||||
protected string VirtualPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var virtualPath = Path.Combine(TempFolder, "VirtualNzbDrone");
|
||||
if (!Directory.Exists(virtualPath)) Directory.CreateDirectory(virtualPath);
|
||||
|
||||
return virtualPath;
|
||||
}
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetupBase()
|
||||
{
|
||||
InitLogging();
|
||||
|
||||
ExceptionVerification.Reset();
|
||||
if (Directory.Exists(TempFolder))
|
||||
{
|
||||
Directory.Delete(TempFolder, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(TempFolder);
|
||||
|
||||
LiveKernel = new StandardKernel();
|
||||
Mocker = new AutoMoqer();
|
||||
}
|
||||
|
||||
protected void WithStrictMocker()
|
||||
{
|
||||
Mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
if (Db != null)
|
||||
{
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
}
|
||||
|
||||
protected void WithRealDb()
|
||||
{
|
||||
Db = MockLib.GetEmptyDatabase();
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDownBase()
|
||||
{
|
||||
ExceptionVerification.AssertNoUnexcpectedLogs();
|
||||
Mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
WebTimer.Stop();
|
||||
}
|
||||
|
||||
|
||||
protected void WithTempAsStartUpPath()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>()
|
||||
.SetupGet(c => c.ApplicationPath)
|
||||
.Returns(VirtualPath);
|
||||
|
||||
Mocker.Resolve<PathProvider>();
|
||||
}
|
||||
|
||||
|
||||
protected string TempFolder
|
||||
{
|
||||
get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); }
|
||||
}
|
||||
|
||||
protected string GetTestFilePath(string fileName)
|
||||
{
|
||||
return Path.Combine(@".\Files\", fileName);
|
||||
}
|
||||
|
||||
protected string ReadTestFile(string fileName)
|
||||
{
|
||||
return File.ReadAllText(GetTestFilePath(fileName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class IndexerTests : TestBase
|
||||
public class IndexerTests : CoreTest
|
||||
{
|
||||
|
||||
[TestCase("nzbsorg.xml", 2)]
|
||||
|
|
|
@ -16,14 +16,14 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class BannerDownloadJobTest : TestBase
|
||||
public class BannerDownloadJobTest : CoreTest
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithStrictMocker();
|
||||
WithTempAsStartUpPath();
|
||||
WithTempAsAppPath();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -90,11 +90,11 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
public void BannerDownload_some_failed_download()
|
||||
{
|
||||
//Setup
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(4)
|
||||
.Build();
|
||||
|
||||
|
||||
var pathProvider = Mocker.Resolve<PathProvider>();
|
||||
var bannerPath = Mocker.GetMock<EnviromentProvider>().Object.GetBannerPath();
|
||||
|
||||
var notification = new ProgressNotification("Banner Download");
|
||||
|
||||
|
@ -103,43 +103,18 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "1.jpg")))
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "1.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "2.jpg")));
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "2.jpg")));
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "3.jpg")))
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "3.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "4.jpg")));
|
||||
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "5.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "6.jpg")));
|
||||
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "7.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "8.jpg")));
|
||||
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "9.jpg")))
|
||||
.Throws(new WebException());
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(pathProvider.BannerPath, "10.jpg")));
|
||||
|
||||
.Setup(s => s.DownloadFile(It.IsAny<string>(), Path.Combine(bannerPath, "4.jpg")));
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(S => S.CreateDirectory(It.IsAny<string>()))
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DiskScanJobTest : TestBase
|
||||
public class DiskScanJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void series_specific_scan_should_scan_series()
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ImportNewSeriesJobTest : TestBase
|
||||
public class ImportNewSeriesJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void import_new_series_succesfull()
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeasonSearchJobTest : TestBase
|
||||
public class SeasonSearchJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeasonSearch_full_season_success()
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeriesSearchJobTest : TestBase
|
||||
public class SeriesSearchJobTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeriesSearch_success()
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
|
||||
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
|
||||
<Compile Include="ProviderTests\ConfigFileProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\FreeDiskSpaceTest.cs" />
|
||||
<Compile Include="ProviderTests\ProwlProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\GrowlProviderTest.cs" />
|
||||
|
@ -115,7 +114,7 @@
|
|||
<Compile Include="ProviderTests\UpcomingEpisodesProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProvider_GetNewFilenameTest.cs" />
|
||||
<Compile Include="dbBenchmark.cs" />
|
||||
<Compile Include="Framework\TestBase.cs" />
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="ProviderTests\InventoryProvider_IsMonitoredTest.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\SearchProviderTest_Episode.cs" />
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ParserTest : TestBase
|
||||
public class ParserTest : CoreTest
|
||||
{
|
||||
/*Fucked-up hall of shame,
|
||||
* WWE.Wrestlemania.27.PPV.HDTV.XviD-KYR
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ConfigProviderTest : TestBase
|
||||
public class ConfigProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Add_new_value_to_database()
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.IO;
|
|||
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ExtractArchiveFixture : TestBase
|
||||
public class ExtractArchiveFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Should_extract_to_correct_folder()
|
||||
|
|
|
@ -14,7 +14,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FreeDiskSpaceTest : TestBase
|
||||
public class FreeDiskSpaceTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void FreeDiskSpace()
|
||||
|
|
|
@ -14,7 +14,7 @@ using NzbDrone.Test.Common;
|
|||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DiskScanProviderTest : TestBase
|
||||
public class DiskScanProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void scan_series_should_update_the_last_scan_date()
|
||||
|
|
|
@ -17,7 +17,7 @@ using NzbDrone.Test.Common;
|
|||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DiskScanProviderTest_ImportFile : TestBase
|
||||
public class DiskScanProviderTest_ImportFile : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void import_new_file_should_succeed()
|
||||
|
|
|
@ -14,7 +14,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadProviderTest : TestBase
|
||||
public class DownloadProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest : TestBase
|
||||
public class EpisodeProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void GetEpisodes_exists()
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_DeleteInvalidEpisodes : TestBase
|
||||
public class EpisodeProviderTest_DeleteInvalidEpisodes : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Delete_None_Valid_TvDbEpisodeId()
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : TestBase
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : CoreTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EventClientProviderTest : TestBase
|
||||
public class EventClientProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SendNotification_true()
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[Explicit]
|
||||
[TestFixture]
|
||||
public class GrowlProviderTest : TestBase
|
||||
public class GrowlProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Register_should_add_new_application_to_local_growl_instance()
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class HistoryProviderTest : TestBase
|
||||
public class HistoryProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void AllItems()
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class IndexerProviderTest : TestBase
|
||||
public class IndexerProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Init_indexer_test()
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class InventoryProvider_IsAcceptableSizeTest : TestBase
|
||||
public class InventoryProvider_IsAcceptableSizeTest : CoreTest
|
||||
{
|
||||
private EpisodeParseResult parseResultMulti;
|
||||
private EpisodeParseResult parseResultSingle;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class InventoryProvider_IsMonitoredTest : TestBase
|
||||
public class InventoryProvider_IsMonitoredTest : CoreTest
|
||||
{
|
||||
private EpisodeParseResult parseResultMulti;
|
||||
private Series series;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class InventoryProvider_QualityNeededTest : TestBase
|
||||
public class InventoryProvider_QualityNeededTest : CoreTest
|
||||
{
|
||||
private Episode episode;
|
||||
private Episode episode2;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class JobProviderTest : TestBase
|
||||
public class JobProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Run_Jobs_Updates_Last_Execution()
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class LogProviderTest : TestBase
|
||||
public class LogProviderTest : CoreTest
|
||||
{
|
||||
|
||||
private const string loggerName = "Core.Test.ProviderTests.LogProviderTest";
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class MediaFileProviderTests : TestBase
|
||||
public class MediaFileProviderTests : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void get_series_files()
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class MediaFileProvider_GetNewFilenameTest : TestBase
|
||||
public class MediaFileProvider_GetNewFilenameTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class PostDownloadProviderFixture : TestBase
|
||||
public class PostDownloadProviderFixture : CoreTest
|
||||
{
|
||||
[TestCase(@"c:\_NzbDrone_InvalidEpisode_Title", @"c:\_UnknownSeries_Title", PostDownloadStatusType.UnknownSeries)]
|
||||
[TestCase(@"c:\Title", @"c:\_Failed_Title", PostDownloadStatusType.Failed)]
|
||||
|
|
|
@ -18,7 +18,7 @@ using NzbDrone.Test.Common;
|
|||
namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProcessDownloadFixture : TestBase
|
||||
public class ProcessDownloadFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void should_skip_if_folder_is_tagged_and_too_fresh()
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[Explicit]
|
||||
[TestFixture]
|
||||
public class ProwlProviderTest : TestBase
|
||||
public class ProwlProviderTest : CoreTest
|
||||
{
|
||||
private const string _apiKey = "c3bdc0f48168f72d546cc6872925b160f5cbffc1";
|
||||
private const string _apiKey2 = "46a710a46b111b0b8633819b0d8a1e0272a3affa";
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class QualityTypeProviderTest : TestBase
|
||||
public class QualityTypeProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SetupDefault_should_add_six_profiles()
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class RootDirProviderTest : TestBase
|
||||
public class RootDirProviderTest : CoreTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SabProviderTest : TestBase
|
||||
public class SabProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void AddByUrlSuccess()
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchProviderTest_Episode : TestBase
|
||||
public class SearchProviderTest_Episode : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void processResults_ParseResult_should_return_after_match()
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchProviderTest_PartialSeason : TestBase
|
||||
public class SearchProviderTest_PartialSeason : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeasonPartialSearch_season_success()
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchProviderTest_Season : TestBase
|
||||
public class SearchProviderTest_Season : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void SeasonSearch_season_success()
|
||||
|
|
|
@ -15,7 +15,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesProviderTest : TestBase
|
||||
public class SeriesProviderTest : CoreTest
|
||||
{
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class TvDbProviderTest : TestBase
|
||||
public class TvDbProviderTest : CoreTest
|
||||
{
|
||||
private TvDbProvider tvDbProvider;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class UpcomingEpisodesProviderTest : TestBase
|
||||
public class UpcomingEpisodesProviderTest : CoreTest
|
||||
{
|
||||
private IList<Episode> episodes;
|
||||
private Series series;
|
||||
|
|
|
@ -10,7 +10,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
{
|
||||
class GetAvilableUpdateFixture : TestBase
|
||||
class GetAvilableUpdateFixture : CoreTest
|
||||
{
|
||||
private AutoMoqer _mocker = null;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
internal class PreformUpdateFixture : TestBase
|
||||
internal class PreformUpdateFixture : CoreTest
|
||||
{
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
|||
[Test]
|
||||
public void Should_call_download_and_extract_using_correct_arguments()
|
||||
{
|
||||
Mocker.GetMock<PathProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
|
@ -54,9 +54,9 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
|||
public void Should_download_and_extract_to_temp_folder()
|
||||
{
|
||||
|
||||
Mocker.GetMock<PathProvider>().SetupGet(c => c.SystemTemp).Returns(TempFolder);
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(TempFolder);
|
||||
|
||||
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<PathProvider>().Object.GetUpdateSandboxFolder());
|
||||
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnviromentProvider>().Object.GetUpdateSandboxFolder());
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class XbmcProviderTest : TestBase
|
||||
public class XbmcProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void JsonError_true()
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class QualityProfileTest : TestBase
|
||||
public class QualityProfileTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_Storage()
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class QualityTest : TestBase
|
||||
public class QualityTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void Icomparer_greater_test()
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SceneMappingTest : TestBase
|
||||
public class SceneMappingTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void GetSceneName_exists()
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SortHelperTest : TestBase
|
||||
public class SortHelperTest : CoreTest
|
||||
{
|
||||
//American Gladiators
|
||||
//Ancient Apocalypse
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test
|
|||
[Explicit]
|
||||
[Category("Benchmark")]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DbBenchmark : TestBase
|
||||
public class DbBenchmark : CoreTest
|
||||
{
|
||||
const int Episodes_Per_Season = 20;
|
||||
private readonly List<int> seasonsNumbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
@ -11,6 +12,7 @@ using NzbDrone.Core.Providers.ExternalNotification;
|
|||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using PetaPoco;
|
||||
using LogConfiguration = NzbDrone.Core.Instrumentation.LogConfiguration;
|
||||
|
||||
namespace NzbDrone.Core
|
||||
{
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using MvcMiniProfiler.Data;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class Connection
|
||||
{
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
|
||||
public Connection(PathProvider pathProvider)
|
||||
public Connection(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_pathProvider = pathProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
}
|
||||
|
||||
static Connection()
|
||||
|
@ -28,7 +22,7 @@ namespace NzbDrone.Core.Datastore
|
|||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(_pathProvider.NzbDronoeDbFile);
|
||||
return GetConnectionString(_enviromentProvider.GetNzbDronoeDbFile());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +30,7 @@ namespace NzbDrone.Core.Datastore
|
|||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(_pathProvider.LogDbFile);
|
||||
return GetConnectionString(_enviromentProvider.GetLogDbFileDbFile());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace NzbDrone.Core.Instrumentation
|
|||
{
|
||||
public class LogConfiguration
|
||||
{
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly DatabaseTarget _databaseTarget;
|
||||
|
||||
public LogConfiguration(PathProvider pathProvider, DatabaseTarget databaseTarget)
|
||||
public LogConfiguration(EnviromentProvider enviromentProvider, DatabaseTarget databaseTarget)
|
||||
{
|
||||
_pathProvider = pathProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_databaseTarget = databaseTarget;
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,13 @@ namespace NzbDrone.Core.Instrumentation
|
|||
LogManager.ThrowExceptions = false;
|
||||
}
|
||||
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(_pathProvider.LogConfigFile, false);
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(_enviromentProvider.GetNlogConfigPath(), false);
|
||||
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
|
||||
|
||||
LogManager.ConfigurationReloaded += ((s, e) => RegisterDatabaseLogger(_databaseTarget));
|
||||
Common.LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
public static void RegisterDatabaseLogger(DatabaseTarget databaseTarget)
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model
|
||||
{
|
||||
public enum AuthenticationType
|
||||
{
|
||||
Anonymous = 0,
|
||||
Windows = 1
|
||||
}
|
||||
}
|
|
@ -197,7 +197,6 @@
|
|||
<Compile Include="Instrumentation\NlogWriter.cs" />
|
||||
<Compile Include="Datastore\PetaPoco\PetaPoco.cs" />
|
||||
<Compile Include="Model\AtomicParsleyTitleType.cs" />
|
||||
<Compile Include="Model\AuthenticationType.cs" />
|
||||
<Compile Include="Model\ConnectionInfoModel.cs" />
|
||||
<Compile Include="Model\PostDownloadStatusType.cs" />
|
||||
<Compile Include="Model\ExternalNotificationType.cs" />
|
||||
|
@ -219,7 +218,6 @@
|
|||
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />
|
||||
<Compile Include="Providers\ExternalNotification\Prowl.cs" />
|
||||
<Compile Include="Providers\ProwlProvider.cs" />
|
||||
<Compile Include="Providers\Core\ConfigFileProvider.cs" />
|
||||
<Compile Include="Providers\Core\UdpProvider.cs" />
|
||||
<Compile Include="Providers\ExternalNotification\Growl.cs" />
|
||||
<Compile Include="Providers\ExternalNotification\Twitter.cs" />
|
||||
|
@ -311,7 +309,7 @@
|
|||
<Compile Include="Repository\Series.cs" />
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\Core\DiskProvider.cs" />
|
||||
<Compile Include="Providers\Core\ArchiveProvider.cs" />
|
||||
<Compile Include="Providers\SeriesProvider.cs" />
|
||||
<Compile Include="Providers\TvDbProvider.cs" />
|
||||
<Compile Include="WebTimer.cs" />
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class ConfigFileProvider
|
||||
{
|
||||
private readonly PathProvider _pathProvider;
|
||||
|
||||
private readonly string _configFile;
|
||||
public ConfigFileProvider(PathProvider pathProvider)
|
||||
{
|
||||
_pathProvider = pathProvider;
|
||||
_configFile = _pathProvider.AppConfigFile;
|
||||
}
|
||||
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetValueInt("Port", 8989); }
|
||||
set { SetValue("Port", value); }
|
||||
}
|
||||
|
||||
public virtual bool LaunchBrowser
|
||||
{
|
||||
get { return GetValueBoolean("LaunchBrowser", true); }
|
||||
set { SetValue("LaunchBrowser", value); }
|
||||
}
|
||||
|
||||
public virtual AuthenticationType AuthenticationType
|
||||
{
|
||||
get { return (AuthenticationType)GetValueInt("AuthenticationType", 0); }
|
||||
set { SetValue("AuthenticationType", (int)value); }
|
||||
}
|
||||
|
||||
public virtual string GetValue(string key, object defaultValue, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
||||
if (!String.IsNullOrEmpty(parent))
|
||||
{
|
||||
//Add the parent
|
||||
if (config.Descendants(parent).Count() != 1)
|
||||
{
|
||||
SetValue(key, defaultValue, parent);
|
||||
|
||||
//Reload the configFile
|
||||
xDoc = XDocument.Load(_configFile);
|
||||
config = xDoc.Descendants("Config").Single();
|
||||
}
|
||||
|
||||
parentContainer = config.Descendants(parent).Single();
|
||||
}
|
||||
|
||||
var valueHolder = parentContainer.Descendants(key).ToList();
|
||||
|
||||
if (valueHolder.Count() == 1)
|
||||
return valueHolder.First().Value;
|
||||
|
||||
//Save the value
|
||||
SetValue(key, defaultValue, parent);
|
||||
|
||||
//return the default value
|
||||
return defaultValue.ToString();
|
||||
}
|
||||
|
||||
public virtual int GetValueInt(string key, int defaultValue, string parent = null)
|
||||
{
|
||||
return Convert.ToInt32(GetValue(key, defaultValue, parent));
|
||||
}
|
||||
|
||||
public virtual bool GetValueBoolean(string key, bool defaultValue, string parent = null)
|
||||
{
|
||||
return Convert.ToBoolean(GetValue(key, defaultValue, parent));
|
||||
}
|
||||
|
||||
public virtual void SetValue(string key, object value, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
||||
if (!String.IsNullOrEmpty(parent))
|
||||
{
|
||||
//Add the parent container if it doesn't already exist
|
||||
if (config.Descendants(parent).Count() != 1)
|
||||
{
|
||||
config.Add(new XElement(parent));
|
||||
}
|
||||
|
||||
parentContainer = config.Descendants(parent).Single();
|
||||
}
|
||||
|
||||
var keyHolder = parentContainer.Descendants(key);
|
||||
|
||||
if (keyHolder.Count() != 1)
|
||||
parentContainer.Add(new XElement(key, value));
|
||||
|
||||
else
|
||||
parentContainer.Descendants(key).Single().Value = value.ToString();
|
||||
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
|
||||
public virtual void CreateDefaultConfigFile()
|
||||
{
|
||||
if (!File.Exists(_configFile))
|
||||
{
|
||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||
|
||||
xDoc.Add(new XElement("Config"));
|
||||
|
||||
xDoc.Save(_configFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,20 +17,18 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
private readonly HttpProvider _httpProvider;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly PathProvider _pathProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private const string _bannerUrlPrefix = "http://www.thetvdb.com/banners/";
|
||||
|
||||
[Inject]
|
||||
public BannerDownloadJob(SeriesProvider seriesProvider, HttpProvider httpProvider, DiskProvider diskProvider,
|
||||
EnviromentProvider enviromentProvider, PathProvider pathProvider)
|
||||
EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_httpProvider = httpProvider;
|
||||
_diskProvider = diskProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_pathProvider = pathProvider;
|
||||
}
|
||||
|
||||
public BannerDownloadJob()
|
||||
|
@ -53,7 +51,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
Logger.Debug("Starting banner download job");
|
||||
|
||||
|
||||
_diskProvider.CreateDirectory(_pathProvider.BannerPath);
|
||||
_diskProvider.CreateDirectory(_enviromentProvider.GetBannerPath());
|
||||
|
||||
if (targetId > 0)
|
||||
{
|
||||
|
@ -77,7 +75,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
|
||||
public virtual void DownloadBanner(ProgressNotification notification, Series series)
|
||||
{
|
||||
var bannerFilename = Path.Combine(_pathProvider.BannerPath, series.SeriesId.ToString()) + ".jpg";
|
||||
var bannerFilename = Path.Combine(_enviromentProvider.GetBannerPath(), series.SeriesId.ToString()) + ".jpg";
|
||||
|
||||
notification.CurrentMessage = string.Format("Downloading banner for '{0}'", series.Title);
|
||||
|
||||
|
|
|
@ -13,15 +13,17 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
public class TvDbProvider
|
||||
{
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private const string TVDB_APIKEY = "5D2D188E86E07F4F";
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly TvdbHandler _handler;
|
||||
|
||||
[Inject]
|
||||
public TvDbProvider(PathProvider pathProvider)
|
||||
public TvDbProvider(EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_handler = new TvdbHandler(new XmlCacheProvider(pathProvider.CacheFolder), TVDB_APIKEY);
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_handler = new TvdbHandler(new XmlCacheProvider(_enviromentProvider.GetCacheFolder()), TVDB_APIKEY);
|
||||
}
|
||||
|
||||
public TvDbProvider()
|
||||
|
|
|
@ -17,24 +17,20 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly HttpProvider _httpProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly ArchiveProvider _archiveProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static readonly Regex ParseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
|
||||
private static readonly Regex parseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
|
||||
|
||||
|
||||
|
||||
[Inject]
|
||||
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, EnviromentProvider enviromentProvider,
|
||||
PathProvider pathProvider, DiskProvider diskProvider, ArchiveProvider archiveProvider)
|
||||
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
|
||||
EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configProvider = configProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_pathProvider = pathProvider;
|
||||
_diskProvider = diskProvider;
|
||||
_archiveProvider = archiveProvider;
|
||||
}
|
||||
|
||||
|
@ -47,7 +43,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
var updateList = new List<UpdatePackage>();
|
||||
var rawUpdateList = _httpProvider.DownloadString(_configProvider.UpdateUrl);
|
||||
var matches = ParseRegex.Matches(rawUpdateList);
|
||||
var matches = parseRegex.Matches(rawUpdateList);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
|
@ -67,25 +63,25 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
if (latestAvailable != null && latestAvailable.Version > _enviromentProvider.Version)
|
||||
{
|
||||
Logger.Debug("An update is available ({0}) => ({1})", _enviromentProvider.Version, latestAvailable.Version);
|
||||
logger.Debug("An update is available ({0}) => ({1})", _enviromentProvider.Version, latestAvailable.Version);
|
||||
return latestAvailable;
|
||||
}
|
||||
|
||||
Logger.Trace("No updates available");
|
||||
logger.Trace("No updates available");
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void StartUpgrade(UpdatePackage updatePackage)
|
||||
{
|
||||
var packageDestination = Path.Combine(_pathProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
|
||||
var packageDestination = Path.Combine(_enviromentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
|
||||
|
||||
Logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
||||
logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
||||
_httpProvider.DownloadFile(updatePackage.Url, packageDestination);
|
||||
Logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
|
||||
logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
|
||||
|
||||
Logger.Info("Extracting Update package");
|
||||
_archiveProvider.ExtractArchive(packageDestination, _pathProvider.GetUpdateSandboxFolder());
|
||||
Logger.Info("Update package extracted successfully");
|
||||
logger.Info("Extracting Update package");
|
||||
_archiveProvider.ExtractArchive(packageDestination, _enviromentProvider.GetUpdateSandboxFolder());
|
||||
logger.Info("Update package extracted successfully");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using NLog;
|
||||
using NLog.Config;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Test.Common
|
||||
|
@ -15,6 +16,7 @@ namespace NzbDrone.Test.Common
|
|||
LogConfiguration.RegisterUdpLogger();
|
||||
|
||||
RegisterExceptionVerification();
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +25,19 @@ namespace NzbDrone.Test.Common
|
|||
var exceptionVerification = new ExceptionVerification();
|
||||
LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, exceptionVerification));
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void LoggingTestSetup()
|
||||
{
|
||||
InitLogging();
|
||||
ExceptionVerification.Reset();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void LoggingDownBase()
|
||||
{
|
||||
ExceptionVerification.AssertNoUnexcpectedLogs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<Compile Include="ExceptionVerification.cs" />
|
||||
<Compile Include="LoggingTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestBase.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="AutoMoq\License.txt" />
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
using System.Linq;
|
||||
using System.IO;
|
||||
using AutoMoq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Test.Common
|
||||
{
|
||||
public class TestBase : LoggingTest
|
||||
// ReSharper disable InconsistentNaming
|
||||
{
|
||||
protected AutoMoqer Mocker;
|
||||
|
||||
protected string VirtualPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var virtualPath = Path.Combine(TempFolder, "VirtualNzbDrone");
|
||||
if (!Directory.Exists(virtualPath)) Directory.CreateDirectory(virtualPath);
|
||||
|
||||
return virtualPath;
|
||||
}
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual void TestBaseSetup()
|
||||
{
|
||||
if (Directory.Exists(TempFolder))
|
||||
{
|
||||
Directory.Delete(TempFolder, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(TempFolder);
|
||||
|
||||
Mocker = new AutoMoqer();
|
||||
}
|
||||
|
||||
protected virtual void WithStrictMocker()
|
||||
{
|
||||
Mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
}
|
||||
|
||||
|
||||
protected void WithTempAsAppPath()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>()
|
||||
.SetupGet(c => c.ApplicationPath)
|
||||
.Returns(VirtualPath);
|
||||
}
|
||||
|
||||
|
||||
protected string TempFolder
|
||||
{
|
||||
get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); }
|
||||
}
|
||||
|
||||
protected string GetTestFilePath(string fileName)
|
||||
{
|
||||
return Path.Combine(@".\Files\", fileName);
|
||||
}
|
||||
|
||||
protected string ReadTestFile(string fileName)
|
||||
{
|
||||
return File.ReadAllText(GetTestFilePath(fileName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Update.Test
|
|||
private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\";
|
||||
private const string TARGET_FOLDER = @"C:\NzbDrone\";
|
||||
|
||||
Mock<PathProvider> _pathProvider;
|
||||
Mock<EnviromentProvider> _enviromentProvider;
|
||||
|
||||
|
||||
[SetUp]
|
||||
|
@ -26,9 +26,9 @@ namespace NzbDrone.Update.Test
|
|||
{
|
||||
mocker = new AutoMoqer();
|
||||
|
||||
_pathProvider = mocker.GetMock<PathProvider>();
|
||||
_enviromentProvider = mocker.GetMock<EnviromentProvider>();
|
||||
|
||||
_pathProvider.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
_enviromentProvider.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
mocker.GetMock<DiskProvider>()
|
||||
.Setup(c => c.FolderExists(UPDATE_FOLDER))
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Update.Test
|
|||
mocker.GetMock<EnviromentProvider>()
|
||||
.Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\");
|
||||
|
||||
mocker.GetMock<PathProvider>()
|
||||
mocker.GetMock<EnviromentProvider>()
|
||||
.Setup(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
}
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@ namespace NzbDrone.Update.Providers
|
|||
private readonly DiskProvider _diskProvider;
|
||||
private readonly ServiceProvider _serviceProvider;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
private readonly PathProvider _pathProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UpdateProvider(DiskProvider diskProvider,ServiceProvider serviceProvider,
|
||||
ProcessProvider processProvider, PathProvider pathProvider)
|
||||
ProcessProvider processProvider, EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_serviceProvider = serviceProvider;
|
||||
_processProvider = processProvider;
|
||||
_pathProvider = pathProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
}
|
||||
|
||||
private void Verify(string targetFolder)
|
||||
|
@ -34,8 +34,8 @@ namespace NzbDrone.Update.Providers
|
|||
throw new DirectoryNotFoundException("Target folder doesn't exist " + targetFolder);
|
||||
|
||||
logger.Info("Verifying Update Folder");
|
||||
if (!_diskProvider.FolderExists(_pathProvider.GetUpdatePackageFolder()))
|
||||
throw new DirectoryNotFoundException("Update folder doesn't exist " + _pathProvider.GetUpdatePackageFolder());
|
||||
if (!_diskProvider.FolderExists(_enviromentProvider.GetUpdatePackageFolder()))
|
||||
throw new DirectoryNotFoundException("Update folder doesn't exist " + _enviromentProvider.GetUpdatePackageFolder());
|
||||
|
||||
}
|
||||
|
||||
|
@ -62,14 +62,14 @@ namespace NzbDrone.Update.Providers
|
|||
}
|
||||
|
||||
logger.Info("Creating backup of existing installation");
|
||||
_diskProvider.CopyDirectory(targetFolder, _pathProvider.GetUpdateBackUpFolder());
|
||||
_diskProvider.CopyDirectory(targetFolder, _enviromentProvider.GetUpdateBackUpFolder());
|
||||
|
||||
|
||||
logger.Info("Copying update package to target");
|
||||
|
||||
try
|
||||
{
|
||||
_diskProvider.CopyDirectory(_pathProvider.GetUpdatePackageFolder(), targetFolder);
|
||||
_diskProvider.CopyDirectory(_enviromentProvider.GetUpdatePackageFolder(), targetFolder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ namespace NzbDrone.Update.Providers
|
|||
private void RollBack(string targetFolder)
|
||||
{
|
||||
logger.Info("Attempting to rollback upgrade");
|
||||
_diskProvider.CopyDirectory(_pathProvider.GetUpdateBackUpFolder(), targetFolder);
|
||||
_diskProvider.CopyDirectory(_enviromentProvider.GetUpdateBackUpFolder(), targetFolder);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Common.Model;
|
||||
|
||||
namespace NzbDrone.Web.Models
|
||||
{
|
||||
|
|
|
@ -6,13 +6,14 @@ using Ninject;
|
|||
using NzbDrone.Common;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public class ApplicationServer : ServiceBase
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("Host.App");
|
||||
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly ConfigFileProvider _configFileProvider;
|
||||
private readonly DebuggerProvider _debuggerProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly IISProvider _iisProvider;
|
||||
|
@ -21,11 +22,11 @@ namespace NzbDrone
|
|||
private readonly WebClient _webClient;
|
||||
|
||||
[Inject]
|
||||
public ApplicationServer(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider,
|
||||
public ApplicationServer(ConfigFileProvider configFileProvider, WebClient webClient, IISProvider iisProvider,
|
||||
DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider,
|
||||
ProcessProvider processProvider, MonitoringProvider monitoringProvider)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
_configFileProvider = configFileProvider;
|
||||
_webClient = webClient;
|
||||
_iisProvider = iisProvider;
|
||||
_debuggerProvider = debuggerProvider;
|
||||
|
@ -51,7 +52,7 @@ namespace NzbDrone
|
|||
|
||||
_debuggerProvider.Attach();
|
||||
|
||||
if (_enviromentProvider.IsUserInteractive && _configProvider.LaunchBrowser)
|
||||
if (_enviromentProvider.IsUserInteractive && _configFileProvider.LaunchBrowser)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace NzbDrone
|
|||
{
|
||||
_kernel = new StandardKernel();
|
||||
_kernel.Bind<ApplicationServer>().ToSelf().InSingletonScope();
|
||||
_kernel.Bind<ConfigProvider>().ToSelf().InSingletonScope();
|
||||
_kernel.Bind<ConfigFileProvider>().ToSelf().InSingletonScope();
|
||||
_kernel.Bind<ConsoleProvider>().ToSelf().InSingletonScope();
|
||||
_kernel.Bind<DebuggerProvider>().ToSelf().InSingletonScope();
|
||||
_kernel.Bind<EnviromentProvider>().ToSelf().InSingletonScope();
|
||||
|
@ -45,7 +45,9 @@ namespace NzbDrone
|
|||
{
|
||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
|
||||
LogConfiguration.RegisterUdpLogger();
|
||||
_kernel.Get<ConfigProvider>().CreateDefaultConfigFile();
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
LogConfiguration.Reload();
|
||||
_kernel.Get<ConfigFileProvider>().CreateDefaultConfigFile();
|
||||
Logger.Info("Start-up Path:'{0}'", _kernel.Get<EnviromentProvider>().ApplicationPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Model
|
||||
{
|
||||
public enum AuthenticationType
|
||||
{
|
||||
Anonymous = 0,
|
||||
Windows = 1
|
||||
}
|
||||
}
|
|
@ -85,10 +85,8 @@
|
|||
</Compile>
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
<Compile Include="Model\ApplicationMode.cs" />
|
||||
<Compile Include="Model\AuthenticationType.cs" />
|
||||
<Compile Include="Providers\DebuggerProvider.cs" />
|
||||
<Compile Include="ProcessAttacher.cs" />
|
||||
<Compile Include="Providers\ConfigProvider.cs" />
|
||||
<Compile Include="Providers\IISProvider.cs" />
|
||||
<Compile Include="AppMain.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
@ -12,15 +12,15 @@ namespace NzbDrone.Providers
|
|||
{
|
||||
private static readonly Logger IISLogger = LogManager.GetLogger("Host.IISExpress");
|
||||
private static readonly Logger Logger = LogManager.GetLogger("Host.IISProvider");
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly ConfigFileProvider _configFileProvider;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
|
||||
|
||||
[Inject]
|
||||
public IISProvider(ConfigProvider configProvider, ProcessProvider processProvider, EnviromentProvider enviromentProvider)
|
||||
public IISProvider(ConfigFileProvider configFileProvider, ProcessProvider processProvider, EnviromentProvider enviromentProvider)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
_configFileProvider = configFileProvider;
|
||||
_processProvider = processProvider;
|
||||
_enviromentProvider = enviromentProvider;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace NzbDrone.Providers
|
|||
|
||||
public string AppUrl
|
||||
{
|
||||
get { return string.Format("http://localhost:{0}/", _configProvider.PortNumber); }
|
||||
get { return string.Format("http://localhost:{0}/", _configFileProvider.Port); }
|
||||
}
|
||||
|
||||
public int IISProcessId { get; private set; }
|
||||
|
@ -44,8 +44,8 @@ namespace NzbDrone.Providers
|
|||
|
||||
var startInfo = new ProcessStartInfo();
|
||||
|
||||
startInfo.FileName = _configProvider.IISExePath;
|
||||
startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _configProvider.IISConfigPath);
|
||||
startInfo.FileName = _enviromentProvider.GetIISExe();
|
||||
startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _enviromentProvider.GetIISExe());
|
||||
startInfo.WorkingDirectory = _enviromentProvider.ApplicationPath;
|
||||
|
||||
startInfo.UseShellExecute = false;
|
||||
|
@ -59,7 +59,7 @@ namespace NzbDrone.Providers
|
|||
|
||||
try
|
||||
{
|
||||
_configProvider.UpdateIISConfig(_configProvider.IISConfigPath);
|
||||
_configFileProvider.UpdateIISConfig(_enviromentProvider.GetIISConfigPath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ namespace NzbDrone.Providers
|
|||
foreach (var process in _processProvider.GetProcessByName("IISExpress"))
|
||||
{
|
||||
Logger.Info("[{0}]IIS Process found. Path:{1}", process.Id, process.StartPath);
|
||||
if (NormalizePath(process.StartPath) == NormalizePath(_configProvider.IISExePath))
|
||||
if (NormalizePath(process.StartPath) == NormalizePath(_enviromentProvider.GetIISExe()))
|
||||
{
|
||||
Logger.Info("[{0}]Process is considered orphaned.", process.Id);
|
||||
_processProvider.Kill(process.Id);
|
||||
|
|
Loading…
Reference in New Issue