Fixed spelling of enviroment provider (Environment). :)
This commit is contained in:
parent
5764059f1d
commit
a00c20c1af
|
@ -51,7 +51,7 @@ namespace NzbDrone.App.Test
|
||||||
serviceProviderMock.Setup(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
serviceProviderMock.Setup(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
||||||
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
||||||
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
|
Mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace NzbDrone.App.Test
|
||||||
{
|
{
|
||||||
var serviceProviderMock = Mocker.GetMock<ServiceProvider>();
|
var serviceProviderMock = Mocker.GetMock<ServiceProvider>();
|
||||||
serviceProviderMock.Setup(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
serviceProviderMock.Setup(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
|
Mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
|
||||||
|
@ -79,7 +79,7 @@ namespace NzbDrone.App.Test
|
||||||
var appServerProvider = Mocker.GetMock<ApplicationServer>();
|
var appServerProvider = Mocker.GetMock<ApplicationServer>();
|
||||||
consoleProvider.Setup(c => c.WaitForClose());
|
consoleProvider.Setup(c => c.WaitForClose());
|
||||||
appServerProvider.Setup(c => c.Start());
|
appServerProvider.Setup(c => c.Start());
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
Mocker.Resolve<Router>().Route(ApplicationMode.Console);
|
Mocker.Resolve<Router>().Route(ApplicationMode.Console);
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.App.Test
|
||||||
[TestCase(ApplicationMode.Help)]
|
[TestCase(ApplicationMode.Help)]
|
||||||
public void Route_should_call_service_start_when_run_in_service_more(ApplicationMode applicationMode)
|
public void Route_should_call_service_start_when_run_in_service_more(ApplicationMode applicationMode)
|
||||||
{
|
{
|
||||||
var envMock = Mocker.GetMock<EnviromentProvider>();
|
var envMock = Mocker.GetMock<EnvironmentProvider>();
|
||||||
var serviceProvider = Mocker.GetMock<ServiceProvider>();
|
var serviceProvider = Mocker.GetMock<ServiceProvider>();
|
||||||
|
|
||||||
envMock.SetupGet(c => c.IsUserInteractive).Returns(false);
|
envMock.SetupGet(c => c.IsUserInteractive).Returns(false);
|
||||||
|
@ -111,7 +111,7 @@ namespace NzbDrone.App.Test
|
||||||
{
|
{
|
||||||
var consoleMock = Mocker.GetMock<ConsoleProvider>();
|
var consoleMock = Mocker.GetMock<ConsoleProvider>();
|
||||||
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
|
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
|
||||||
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
||||||
|
@ -126,7 +126,7 @@ namespace NzbDrone.App.Test
|
||||||
{
|
{
|
||||||
var consoleMock = Mocker.GetMock<ConsoleProvider>();
|
var consoleMock = Mocker.GetMock<ConsoleProvider>();
|
||||||
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
var serviceMock = Mocker.GetMock<ServiceProvider>();
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||||
|
|
||||||
consoleMock.Setup(c => c.PrintServiceDoestExist());
|
consoleMock.Setup(c => c.PrintServiceDoestExist());
|
||||||
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Common.Test
|
||||||
WithTempAsAppPath();
|
WithTempAsAppPath();
|
||||||
|
|
||||||
//Reset config file
|
//Reset config file
|
||||||
var configFile = Mocker.Resolve<EnviromentProvider>().GetConfigPath();
|
var configFile = Mocker.Resolve<EnvironmentProvider>().GetConfigPath();
|
||||||
|
|
||||||
if (File.Exists(configFile))
|
if (File.Exists(configFile))
|
||||||
File.Delete(configFile);
|
File.Delete(configFile);
|
||||||
|
|
|
@ -162,7 +162,7 @@ namespace NzbDrone.Common.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void folder_should_return_correct_value_for_last_write()
|
public void folder_should_return_correct_value_for_last_write()
|
||||||
{
|
{
|
||||||
var appPath = new EnviromentProvider().ApplicationPath;
|
var appPath = new EnvironmentProvider().ApplicationPath;
|
||||||
Mocker.Resolve<DiskProvider>().GetLastDirectoryWrite(appPath).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-10));
|
Mocker.Resolve<DiskProvider>().GetLastDirectoryWrite(appPath).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-10));
|
||||||
Mocker.Resolve<DiskProvider>().GetLastDirectoryWrite(appPath).Should().BeBefore(DateTime.UtcNow);
|
Mocker.Resolve<DiskProvider>().GetLastDirectoryWrite(appPath).Should().BeBefore(DateTime.UtcNow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,61 +11,61 @@ namespace NzbDrone.Common.Test
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class EnviromentProviderTest : TestBase
|
public class EnviromentProviderTest : TestBase
|
||||||
{
|
{
|
||||||
readonly EnviromentProvider enviromentProvider = new EnviromentProvider();
|
readonly EnvironmentProvider environmentProvider = new EnvironmentProvider();
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void StartupPath_should_not_be_empty()
|
public void StartupPath_should_not_be_empty()
|
||||||
{
|
{
|
||||||
enviromentProvider.StartUpPath.Should().NotBeBlank();
|
environmentProvider.StartUpPath.Should().NotBeBlank();
|
||||||
Path.IsPathRooted(enviromentProvider.StartUpPath).Should().BeTrue("Path is not rooted");
|
Path.IsPathRooted(environmentProvider.StartUpPath).Should().BeTrue("Path is not rooted");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ApplicationPath_should_not_be_empty()
|
public void ApplicationPath_should_not_be_empty()
|
||||||
{
|
{
|
||||||
enviromentProvider.ApplicationPath.Should().NotBeBlank();
|
environmentProvider.ApplicationPath.Should().NotBeBlank();
|
||||||
Path.IsPathRooted(enviromentProvider.ApplicationPath).Should().BeTrue("Path is not rooted");
|
Path.IsPathRooted(environmentProvider.ApplicationPath).Should().BeTrue("Path is not rooted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ApplicationPath_should_find_root_in_current_folder()
|
public void ApplicationPath_should_find_root_in_current_folder()
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(EnviromentProvider.ROOT_MARKER);
|
Directory.CreateDirectory(EnvironmentProvider.ROOT_MARKER);
|
||||||
enviromentProvider.ApplicationPath.Should().BeEquivalentTo(Directory.GetCurrentDirectory());
|
environmentProvider.ApplicationPath.Should().BeEquivalentTo(Directory.GetCurrentDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void crawl_should_return_null_if_cant_find_root()
|
public void crawl_should_return_null_if_cant_find_root()
|
||||||
{
|
{
|
||||||
enviromentProvider.CrawlToRoot("C:\\").Should().BeNullOrEmpty();
|
environmentProvider.CrawlToRoot("C:\\").Should().BeNullOrEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_go_up_the_tree_to_find_iis()
|
public void should_go_up_the_tree_to_find_iis()
|
||||||
{
|
{
|
||||||
enviromentProvider.ApplicationPath.Should().NotBe(Environment.CurrentDirectory);
|
environmentProvider.ApplicationPath.Should().NotBe(Environment.CurrentDirectory);
|
||||||
enviromentProvider.ApplicationPath.Should().NotBe(enviromentProvider.StartUpPath);
|
environmentProvider.ApplicationPath.Should().NotBe(environmentProvider.StartUpPath);
|
||||||
}
|
}
|
||||||
[Test]
|
[Test]
|
||||||
public void IsProduction_should_return_false_when_run_within_nunit()
|
public void IsProduction_should_return_false_when_run_within_nunit()
|
||||||
{
|
{
|
||||||
EnviromentProvider.IsProduction.Should().BeFalse();
|
EnvironmentProvider.IsProduction.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("0.0.0.0")]
|
[TestCase("0.0.0.0")]
|
||||||
[TestCase("1.0.0.0")]
|
[TestCase("1.0.0.0")]
|
||||||
public void Application_version_should_not_be_default(string version)
|
public void Application_version_should_not_be_default(string version)
|
||||||
{
|
{
|
||||||
enviromentProvider.Version.Should().NotBe(new Version(version));
|
environmentProvider.Version.Should().NotBe(new Version(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TearDown]
|
[TearDown]
|
||||||
public void TearDown()
|
public void TearDown()
|
||||||
{
|
{
|
||||||
if (Directory.Exists(EnviromentProvider.ROOT_MARKER))
|
if (Directory.Exists(EnvironmentProvider.ROOT_MARKER))
|
||||||
Directory.Delete(EnviromentProvider.ROOT_MARKER);
|
Directory.Delete(EnvironmentProvider.ROOT_MARKER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace NzbDrone.Common.Test
|
||||||
public class PathExtentionFixture : TestBase
|
public class PathExtentionFixture : TestBase
|
||||||
{
|
{
|
||||||
|
|
||||||
private EnviromentProvider GetEnviromentProvider()
|
private EnvironmentProvider GetEnviromentProvider()
|
||||||
{
|
{
|
||||||
var envMoq = new Mock<EnviromentProvider>();
|
var envMoq = new Mock<EnvironmentProvider>();
|
||||||
|
|
||||||
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace NzbDrone.Common.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void report_parse_error()
|
public void report_parse_error()
|
||||||
{
|
{
|
||||||
ReportingService.RestProvider = new RestProvider(new EnviromentProvider());
|
ReportingService.RestProvider = new RestProvider(new EnvironmentProvider());
|
||||||
ReportingService.ReportParseError("Test error");
|
ReportingService.ReportParseError("Test error");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,16 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
public class ConfigFileProvider
|
public class ConfigFileProvider
|
||||||
{
|
{
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly string _configFile;
|
private readonly string _configFile;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public ConfigFileProvider(EnviromentProvider enviromentProvider)
|
public ConfigFileProvider(EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_configFile = _enviromentProvider.GetConfigPath();
|
_configFile = _environmentProvider.GetConfigPath();
|
||||||
|
|
||||||
CreateDefaultConfigFile();
|
CreateDefaultConfigFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Reflection;
|
||||||
|
|
||||||
namespace NzbDrone.Common
|
namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
public class EnviromentProvider
|
public class EnvironmentProvider
|
||||||
{
|
{
|
||||||
public const string NZBDRONE_PATH = "NZBDRONE_PATH";
|
public const string NZBDRONE_PATH = "NZBDRONE_PATH";
|
||||||
public const string NZBDRONE_PID = "NZBDRONE_PID";
|
public const string NZBDRONE_PID = "NZBDRONE_PID";
|
||||||
|
@ -13,7 +13,7 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
private static readonly string processName = Process.GetCurrentProcess().ProcessName.ToLower();
|
private static readonly string processName = Process.GetCurrentProcess().ProcessName.ToLower();
|
||||||
|
|
||||||
private static readonly EnviromentProvider instance = new EnviromentProvider();
|
private static readonly EnvironmentProvider instance = new EnvironmentProvider();
|
||||||
|
|
||||||
public static bool IsProduction
|
public static bool IsProduction
|
||||||
{
|
{
|
|
@ -12,15 +12,15 @@ namespace NzbDrone.Common
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly ConfigFileProvider _configFileProvider;
|
private readonly ConfigFileProvider _configFileProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public IISProvider(ConfigFileProvider configFileProvider, ProcessProvider processProvider, EnviromentProvider enviromentProvider)
|
public IISProvider(ConfigFileProvider configFileProvider, ProcessProvider processProvider, EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IISProvider()
|
public IISProvider()
|
||||||
|
@ -42,9 +42,9 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo();
|
var startInfo = new ProcessStartInfo();
|
||||||
|
|
||||||
startInfo.FileName = _enviromentProvider.GetIISExe();
|
startInfo.FileName = _environmentProvider.GetIISExe();
|
||||||
startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _enviromentProvider.GetIISConfigPath());
|
startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _environmentProvider.GetIISConfigPath());
|
||||||
startInfo.WorkingDirectory = _enviromentProvider.ApplicationPath;
|
startInfo.WorkingDirectory = _environmentProvider.ApplicationPath;
|
||||||
|
|
||||||
startInfo.UseShellExecute = false;
|
startInfo.UseShellExecute = false;
|
||||||
startInfo.RedirectStandardOutput = true;
|
startInfo.RedirectStandardOutput = true;
|
||||||
|
@ -52,12 +52,12 @@ namespace NzbDrone.Common
|
||||||
startInfo.CreateNoWindow = true;
|
startInfo.CreateNoWindow = true;
|
||||||
|
|
||||||
|
|
||||||
startInfo.EnvironmentVariables[EnviromentProvider.NZBDRONE_PATH] = _enviromentProvider.ApplicationPath;
|
startInfo.EnvironmentVariables[EnvironmentProvider.NZBDRONE_PATH] = _environmentProvider.ApplicationPath;
|
||||||
startInfo.EnvironmentVariables[EnviromentProvider.NZBDRONE_PID] = Process.GetCurrentProcess().Id.ToString();
|
startInfo.EnvironmentVariables[EnvironmentProvider.NZBDRONE_PID] = Process.GetCurrentProcess().Id.ToString();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_configFileProvider.UpdateIISConfig(_enviromentProvider.GetIISConfigPath());
|
_configFileProvider.UpdateIISConfig(_environmentProvider.GetIISConfigPath());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ namespace NzbDrone.Common
|
||||||
foreach (var process in _processProvider.GetProcessByName("IISExpress"))
|
foreach (var process in _processProvider.GetProcessByName("IISExpress"))
|
||||||
{
|
{
|
||||||
Logger.Info("[{0}]IIS Process found. Path:{1}", process.Id, process.StartPath);
|
Logger.Info("[{0}]IIS Process found. Path:{1}", process.Id, process.StartPath);
|
||||||
if (DiskProvider.PathEquals(process.StartPath, _enviromentProvider.GetIISExe()))
|
if (DiskProvider.PathEquals(process.StartPath, _environmentProvider.GetIISExe()))
|
||||||
{
|
{
|
||||||
Logger.Info("[{0}]Process is considered orphaned.", process.Id);
|
Logger.Info("[{0}]Process is considered orphaned.", process.Id);
|
||||||
_processProvider.Kill(process.Id);
|
_processProvider.Kill(process.Id);
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
static LogConfiguration()
|
static LogConfiguration()
|
||||||
{
|
{
|
||||||
if (EnviromentProvider.IsProduction)
|
if (EnvironmentProvider.IsProduction)
|
||||||
{
|
{
|
||||||
LogManager.ThrowExceptions = false;
|
LogManager.ThrowExceptions = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ namespace NzbDrone.Common.NlogTargets
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private static readonly Version version = new EnviromentProvider().Version;
|
private static readonly Version version = new EnvironmentProvider().Version;
|
||||||
|
|
||||||
protected override void Write(LogEventInfo logEvent)
|
protected override void Write(LogEventInfo logEvent)
|
||||||
{
|
{
|
||||||
if (logEvent == null || logEvent.Exception == null || !EnviromentProvider.IsProduction) return;
|
if (logEvent == null || logEvent.Exception == null || !EnvironmentProvider.IsProduction) return;
|
||||||
|
|
||||||
Logger.Trace("Sending Exception to Exceptioneer. Process Name: {0}", Process.GetCurrentProcess().ProcessName);
|
Logger.Trace("Sending Exception to Exceptioneer. Process Name: {0}", Process.GetCurrentProcess().ProcessName);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
<Compile Include="Model\AuthenticationType.cs" />
|
<Compile Include="Model\AuthenticationType.cs" />
|
||||||
<Compile Include="PathExtentions.cs" />
|
<Compile Include="PathExtentions.cs" />
|
||||||
<Compile Include="DiskProvider.cs" />
|
<Compile Include="DiskProvider.cs" />
|
||||||
<Compile Include="EnviromentProvider.cs" />
|
<Compile Include="EnvironmentProvider.cs" />
|
||||||
<Compile Include="NlogTargets\ExceptioneerTarget.cs" />
|
<Compile Include="NlogTargets\ExceptioneerTarget.cs" />
|
||||||
<Compile Include="LogConfiguration.cs" />
|
<Compile Include="LogConfiguration.cs" />
|
||||||
<Compile Include="Model\ProcessInfo.cs" />
|
<Compile Include="Model\ProcessInfo.cs" />
|
||||||
|
|
|
@ -42,119 +42,119 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string GetIISFolder(this EnviromentProvider enviromentProvider)
|
public static string GetIISFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, IIS_FOLDER);
|
return Path.Combine(environmentProvider.ApplicationPath, IIS_FOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetIISExe(this EnviromentProvider enviromentProvider)
|
public static string GetIISExe(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetIISFolder(), IIS_EXE);
|
return Path.Combine(environmentProvider.GetIISFolder(), IIS_EXE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetIISConfigPath(this EnviromentProvider enviromentProvider)
|
public static string GetIISConfigPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetIISFolder(), "AppServer", "applicationhost.config");
|
return Path.Combine(environmentProvider.GetIISFolder(), "AppServer", "applicationhost.config");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetWebRoot(this EnviromentProvider enviromentProvider)
|
public static string GetWebRoot(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, WEB_FOLDER);
|
return Path.Combine(environmentProvider.ApplicationPath, WEB_FOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAppDataPath(this EnviromentProvider enviromentProvider)
|
public static string GetAppDataPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetWebRoot(), APP_DATA);
|
return Path.Combine(environmentProvider.GetWebRoot(), APP_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetNlogConfigPath(this EnviromentProvider enviromentProvider)
|
public static string GetNlogConfigPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetWebRoot(), LOG_CONFIG_FILE);
|
return Path.Combine(environmentProvider.GetWebRoot(), LOG_CONFIG_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetConfigPath(this EnviromentProvider enviromentProvider)
|
public static string GetConfigPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, APP_CONFIG_FILE);
|
return Path.Combine(environmentProvider.ApplicationPath, APP_CONFIG_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetNzbDronoeDbFile(this EnviromentProvider enviromentProvider)
|
public static string GetNzbDronoeDbFile(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetAppDataPath(), NZBDRONE_DB_FILE);
|
return Path.Combine(environmentProvider.GetAppDataPath(), NZBDRONE_DB_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetLogDbFileDbFile(this EnviromentProvider enviromentProvider)
|
public static string GetLogDbFileDbFile(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetAppDataPath(), LOG_DB_FILE);
|
return Path.Combine(environmentProvider.GetAppDataPath(), LOG_DB_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetMediaCoverPath(this EnviromentProvider enviromentProvider)
|
public static string GetMediaCoverPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetWebRoot(), "MediaCover");
|
return Path.Combine(environmentProvider.GetWebRoot(), "MediaCover");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetBannerPath(this EnviromentProvider enviromentProvider)
|
public static string GetBannerPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Banners");
|
return Path.Combine(environmentProvider.GetMediaCoverPath(), "Banners");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetFanArtPath(this EnviromentProvider enviromentProvider)
|
public static string GetFanArtPath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetMediaCoverPath(), "Fanarts");
|
return Path.Combine(environmentProvider.GetMediaCoverPath(), "Fanarts");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCacheFolder(this EnviromentProvider enviromentProvider)
|
public static string GetCacheFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetWebRoot(), "Cache");
|
return Path.Combine(environmentProvider.GetWebRoot(), "Cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdateLogFolder(this EnviromentProvider enviromentProvider)
|
public static string GetUpdateLogFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, UPDATE_LOG_FOLDER_NAME);
|
return Path.Combine(environmentProvider.ApplicationPath, UPDATE_LOG_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdateSandboxFolder(this EnviromentProvider enviromentProvider)
|
public static string GetUpdateSandboxFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME);
|
return Path.Combine(environmentProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdateBackUpFolder(this EnviromentProvider enviromentProvider)
|
public static string GetUpdateBackUpFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_BACKUP_FOLDER_NAME);
|
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_BACKUP_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdatePackageFolder(this EnviromentProvider enviromentProvider)
|
public static string GetUpdatePackageFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME);
|
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdateClientFolder(this EnviromentProvider enviromentProvider)
|
public static string GetUpdateClientFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetUpdatePackageFolder(), UPDATE_CLIENT_FOLDER_NAME);
|
return Path.Combine(environmentProvider.GetUpdatePackageFolder(), UPDATE_CLIENT_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdateClientExePath(this EnviromentProvider enviromentProvider)
|
public static string GetUpdateClientExePath(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_CLIENT_EXE);
|
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_CLIENT_EXE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSandboxLogFolder(this EnviromentProvider enviromentProvider)
|
public static string GetSandboxLogFolder(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_LOG_FOLDER_NAME);
|
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_LOG_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetLogFileName(this EnviromentProvider enviromentProvider)
|
public static string GetLogFileName(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.txt");
|
return Path.Combine(environmentProvider.ApplicationPath, "nzbdrone.log.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetArchivedLogFileName(this EnviromentProvider enviromentProvider)
|
public static string GetArchivedLogFileName(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.0.txt");
|
return Path.Combine(environmentProvider.ApplicationPath, "nzbdrone.log.0.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetConfigBackupFile(this EnviromentProvider enviromentProvider)
|
public static string GetConfigBackupFile(this EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(enviromentProvider.GetAppDataPath(), BACKUP_ZIP_FILE);
|
return Path.Combine(environmentProvider.GetAppDataPath(), BACKUP_ZIP_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -44,7 +44,7 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!EnviromentProvider.IsProduction)
|
if (!EnvironmentProvider.IsProduction)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!EnviromentProvider.IsProduction)
|
if (!EnvironmentProvider.IsProduction)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -84,10 +84,10 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
if(RestProvider == null)
|
if(RestProvider == null)
|
||||||
{
|
{
|
||||||
if(EnviromentProvider.IsProduction)
|
if(EnvironmentProvider.IsProduction)
|
||||||
{
|
{
|
||||||
logger.Warn("Rest provider wasn't provided. creating new one!");
|
logger.Warn("Rest provider wasn't provided. creating new one!");
|
||||||
RestProvider = new RestProvider(new EnviromentProvider());
|
RestProvider = new RestProvider(new EnvironmentProvider());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,13 +16,13 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public RestProvider(EnviromentProvider enviromentProvider)
|
public RestProvider(EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestProvider()
|
public RestProvider()
|
||||||
|
@ -35,9 +35,9 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
public virtual void PostData(string url, ReportBase reportBase)
|
public virtual void PostData(string url, ReportBase reportBase)
|
||||||
{
|
{
|
||||||
reportBase.UGuid = EnviromentProvider.UGuid;
|
reportBase.UGuid = EnvironmentProvider.UGuid;
|
||||||
reportBase.Version = _enviromentProvider.Version.ToString();
|
reportBase.Version = _environmentProvider.Version.ToString();
|
||||||
reportBase.IsProduction = EnviromentProvider.IsProduction;
|
reportBase.IsProduction = EnvironmentProvider.IsProduction;
|
||||||
|
|
||||||
PostData(url, reportBase as object);
|
PostData(url, reportBase as object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,15 @@ namespace NzbDrone.Common
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly ConfigFileProvider _configFileProvider;
|
private readonly ConfigFileProvider _configFileProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public SecurityProvider(ConfigFileProvider configFileProvider, EnviromentProvider enviromentProvider,
|
public SecurityProvider(ConfigFileProvider configFileProvider, EnvironmentProvider environmentProvider,
|
||||||
ProcessProvider processProvider)
|
ProcessProvider processProvider)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
//Skip Url Register if not Vista or 7
|
//Skip Url Register if not Vista or 7
|
||||||
if (_enviromentProvider.GetOsVersion().Major < 6)
|
if (_environmentProvider.GetOsVersion().Major < 6)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Unregister Url (if port != 0)
|
//Unregister Url (if port != 0)
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test
|
||||||
public void app_should_be_marked_as_new_install_if_db_is_initilized_for_the_first_time()
|
public void app_should_be_marked_as_new_install_if_db_is_initilized_for_the_first_time()
|
||||||
{
|
{
|
||||||
WithRealDb();
|
WithRealDb();
|
||||||
EnviromentProvider.RegisterNewInstall.Should().Be(true);
|
EnvironmentProvider.RegisterNewInstall.Should().Be(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete App_data folder
|
//Delete App_data folder
|
||||||
var appData = new EnviromentProvider().GetAppDataPath();
|
var appData = new EnvironmentProvider().GetAppDataPath();
|
||||||
|
|
||||||
if (Directory.Exists(appData))
|
if (Directory.Exists(appData))
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.Integeration
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_able_to_submit_exceptions()
|
public void should_be_able_to_submit_exceptions()
|
||||||
{
|
{
|
||||||
ReportingService.RestProvider = new RestProvider(new EnviromentProvider());
|
ReportingService.RestProvider = new RestProvider(new EnvironmentProvider());
|
||||||
|
|
||||||
var log = new LogEventInfo();
|
var log = new LogEventInfo();
|
||||||
log.LoggerName = "LoggerName.LoggerName.LoggerName.LoggerName";
|
log.LoggerName = "LoggerName.LoggerName.LoggerName.LoggerName";
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||||
Mocker.GetMock<ConfigFileProvider>().SetupGet(c => c.Guid).Returns(_clientGuid);
|
Mocker.GetMock<ConfigFileProvider>().SetupGet(c => c.Guid).Returns(_clientGuid);
|
||||||
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvilableUpdate(It.IsAny<Version>())).Returns(updatePackage);
|
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvilableUpdate(It.IsAny<Version>())).Returns(updatePackage);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
[Test]
|
[Test]
|
||||||
public void Should_copy_update_client_to_root_of_sandbox()
|
public void Should_copy_update_client_to_root_of_sandbox()
|
||||||
{
|
{
|
||||||
var updateClientFolder = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientFolder();
|
var updateClientFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateClientFolder();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
StartUpdate();
|
StartUpdate();
|
||||||
|
@ -107,9 +107,9 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
public void should_start_update_client()
|
public void should_start_update_client()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var updateClientPath = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientExePath();
|
var updateClientPath = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateClientExePath();
|
||||||
|
|
||||||
Mocker.GetMock<EnviromentProvider>()
|
Mocker.GetMock<EnvironmentProvider>()
|
||||||
.SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12);
|
.SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -138,9 +138,9 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
public void Should_download_and_extract_to_temp_folder()
|
public void Should_download_and_extract_to_temp_folder()
|
||||||
{
|
{
|
||||||
|
|
||||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(TempFolder);
|
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.SystemTemp).Returns(TempFolder);
|
||||||
|
|
||||||
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnviromentProvider>().Object.GetUpdateSandboxFolder());
|
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateSandboxFolder());
|
||||||
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void new_install_should_be_registered()
|
public void new_install_should_be_registered()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = true;
|
EnvironmentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
var provider = Mocker.Resolve<AnalyticsProvider>();
|
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void new_install_should_only_be_registered_on_first_call()
|
public void new_install_should_only_be_registered_on_first_call()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = true;
|
EnvironmentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
var provider = Mocker.Resolve<AnalyticsProvider>();
|
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void upgrade_should_not_register_install()
|
public void upgrade_should_not_register_install()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = false;
|
EnvironmentProvider.RegisterNewInstall = false;
|
||||||
|
|
||||||
var provider = Mocker.Resolve<AnalyticsProvider>();
|
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void shouldnt_register_anything_if_not_on_master_branch()
|
public void shouldnt_register_anything_if_not_on_master_branch()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = false;
|
EnvironmentProvider.RegisterNewInstall = false;
|
||||||
|
|
||||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void new_install_shouldnt_register_anything_if_not_on_master_branch()
|
public void new_install_shouldnt_register_anything_if_not_on_master_branch()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = true;
|
EnvironmentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_able_to_call_deskmetrics_using_test_appid()
|
public void should_be_able_to_call_deskmetrics_using_test_appid()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = true;
|
EnvironmentProvider.RegisterNewInstall = true;
|
||||||
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
|
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||||
{
|
{
|
||||||
WithTempAsAppPath();
|
WithTempAsAppPath();
|
||||||
|
|
||||||
UpdateLogFolder = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateLogFolder();
|
UpdateLogFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateLogFolder();
|
||||||
|
|
||||||
Mocker.GetMock<DiskProvider>()
|
Mocker.GetMock<DiskProvider>()
|
||||||
.Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
|
.Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
|
||||||
|
|
|
@ -24,13 +24,13 @@ namespace NzbDrone.Core
|
||||||
public class CentralDispatch
|
public class CentralDispatch
|
||||||
{
|
{
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
public StandardKernel Kernel { get; private set; }
|
public StandardKernel Kernel { get; private set; }
|
||||||
|
|
||||||
public CentralDispatch()
|
public CentralDispatch()
|
||||||
{
|
{
|
||||||
_enviromentProvider = new EnviromentProvider();
|
_environmentProvider = new EnvironmentProvider();
|
||||||
|
|
||||||
logger.Debug("Initializing Kernel:");
|
logger.Debug("Initializing Kernel:");
|
||||||
Kernel = new StandardKernel();
|
Kernel = new StandardKernel();
|
||||||
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core
|
||||||
{
|
{
|
||||||
logger.Info("Initializing Database...");
|
logger.Info("Initializing Database...");
|
||||||
|
|
||||||
var appDataPath = _enviromentProvider.GetAppDataPath();
|
var appDataPath = _environmentProvider.GetAppDataPath();
|
||||||
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
||||||
|
|
||||||
var connection = Kernel.Get<Connection>();
|
var connection = Kernel.Get<Connection>();
|
||||||
|
@ -67,15 +67,15 @@ namespace NzbDrone.Core
|
||||||
|
|
||||||
private void InitReporting()
|
private void InitReporting()
|
||||||
{
|
{
|
||||||
EnviromentProvider.UGuid = Kernel.Get<ConfigProvider>().UGuid;
|
EnvironmentProvider.UGuid = Kernel.Get<ConfigProvider>().UGuid;
|
||||||
ReportingService.RestProvider = Kernel.Get<RestProvider>();
|
ReportingService.RestProvider = Kernel.Get<RestProvider>();
|
||||||
|
|
||||||
var appId = AnalyticsProvider.DESKMETRICS_TEST_ID;
|
var appId = AnalyticsProvider.DESKMETRICS_TEST_ID;
|
||||||
|
|
||||||
if (EnviromentProvider.IsProduction)
|
if (EnvironmentProvider.IsProduction)
|
||||||
appId = AnalyticsProvider.DESKMETRICS_PRODUCTION_ID;
|
appId = AnalyticsProvider.DESKMETRICS_PRODUCTION_ID;
|
||||||
|
|
||||||
var deskMetricsClient = new DeskMetricsClient(Kernel.Get<ConfigProvider>().UGuid.ToString(), appId, _enviromentProvider.Version);
|
var deskMetricsClient = new DeskMetricsClient(Kernel.Get<ConfigProvider>().UGuid.ToString(), appId, _environmentProvider.Version);
|
||||||
Kernel.Bind<IDeskMetricsClient>().ToConstant(deskMetricsClient);
|
Kernel.Bind<IDeskMetricsClient>().ToConstant(deskMetricsClient);
|
||||||
|
|
||||||
Kernel.Get<AnalyticsProvider>().Checkpoint();
|
Kernel.Get<AnalyticsProvider>().Checkpoint();
|
||||||
|
@ -149,7 +149,7 @@ namespace NzbDrone.Core
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pid = _enviromentProvider.NzbDroneProcessIdFromEnviroment;
|
var pid = _environmentProvider.NzbDroneProcessIdFromEnviroment;
|
||||||
|
|
||||||
logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid);
|
logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
public class Connection
|
public class Connection
|
||||||
{
|
{
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
static Connection()
|
static Connection()
|
||||||
{
|
{
|
||||||
|
@ -23,16 +23,16 @@ namespace NzbDrone.Core.Datastore
|
||||||
, "System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
|
, "System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Connection(EnviromentProvider enviromentProvider)
|
public Connection(EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String MainConnectionString
|
public String MainConnectionString
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return GetConnectionString(_enviromentProvider.GetNzbDronoeDbFile());
|
return GetConnectionString(_environmentProvider.GetNzbDronoeDbFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return GetConnectionString(_enviromentProvider.GetLogDbFileDbFile());
|
return GetConnectionString(_environmentProvider.GetLogDbFileDbFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||||
protected override void MainDbUpgrade()
|
protected override void MainDbUpgrade()
|
||||||
{
|
{
|
||||||
//This should not run unless for a clean install
|
//This should not run unless for a clean install
|
||||||
EnviromentProvider.RegisterNewInstall = true;
|
EnvironmentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
Database.AddTable("Series", new[]
|
Database.AddTable("Series", new[]
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,17 +12,17 @@ namespace NzbDrone.Core.Instrumentation
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
private readonly LogDbContext _logDbContext;
|
private readonly LogDbContext _logDbContext;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public LogProvider(IDatabase database, LogDbContext logDbContext, DiskProvider diskProvider, EnviromentProvider enviromentProvider)
|
public LogProvider(IDatabase database, LogDbContext logDbContext, DiskProvider diskProvider, EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
_logDbContext = logDbContext;
|
_logDbContext = logDbContext;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<Log> GetAllLogs()
|
public IQueryable<Log> GetAllLogs()
|
||||||
|
@ -52,8 +52,8 @@ namespace NzbDrone.Core.Instrumentation
|
||||||
public void DeleteAll()
|
public void DeleteAll()
|
||||||
{
|
{
|
||||||
_database.Delete<Log>("");
|
_database.Delete<Log>("");
|
||||||
_diskProvider.DeleteFile(_enviromentProvider.GetLogFileName());
|
_diskProvider.DeleteFile(_environmentProvider.GetLogFileName());
|
||||||
_diskProvider.DeleteFile(_enviromentProvider.GetArchivedLogFileName());
|
_diskProvider.DeleteFile(_environmentProvider.GetArchivedLogFileName());
|
||||||
Logger.Info("Cleared Log History");
|
Logger.Info("Cleared Log History");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Jobs
|
||||||
public class AppUpdateJob : IJob
|
public class AppUpdateJob : IJob
|
||||||
{
|
{
|
||||||
private readonly UpdateProvider _updateProvider;
|
private readonly UpdateProvider _updateProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private readonly HttpProvider _httpProvider;
|
private readonly HttpProvider _httpProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
|
@ -24,11 +24,11 @@ namespace NzbDrone.Core.Jobs
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public AppUpdateJob(UpdateProvider updateProvider, EnviromentProvider enviromentProvider, DiskProvider diskProvider,
|
public AppUpdateJob(UpdateProvider updateProvider, EnvironmentProvider environmentProvider, DiskProvider diskProvider,
|
||||||
HttpProvider httpProvider, ProcessProvider processProvider, ArchiveProvider archiveProvider, ConfigFileProvider configFileProvider)
|
HttpProvider httpProvider, ProcessProvider processProvider, ArchiveProvider archiveProvider, ConfigFileProvider configFileProvider)
|
||||||
{
|
{
|
||||||
_updateProvider = updateProvider;
|
_updateProvider = updateProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
|
@ -50,18 +50,18 @@ namespace NzbDrone.Core.Jobs
|
||||||
{
|
{
|
||||||
notification.CurrentMessage = "Checking for updates";
|
notification.CurrentMessage = "Checking for updates";
|
||||||
|
|
||||||
var updatePackage = _updateProvider.GetAvilableUpdate(_enviromentProvider.Version);
|
var updatePackage = _updateProvider.GetAvilableUpdate(_environmentProvider.Version);
|
||||||
|
|
||||||
//No updates available
|
//No updates available
|
||||||
if (updatePackage == null)
|
if (updatePackage == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var packageDestination = Path.Combine(_enviromentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
|
var packageDestination = Path.Combine(_environmentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
|
||||||
|
|
||||||
if (_diskProvider.FolderExists(_enviromentProvider.GetUpdateSandboxFolder()))
|
if (_diskProvider.FolderExists(_environmentProvider.GetUpdateSandboxFolder()))
|
||||||
{
|
{
|
||||||
logger.Info("Deleting old update files");
|
logger.Info("Deleting old update files");
|
||||||
_diskProvider.DeleteFolder(_enviromentProvider.GetUpdateSandboxFolder(), true);
|
_diskProvider.DeleteFolder(_environmentProvider.GetUpdateSandboxFolder(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
||||||
|
@ -71,19 +71,19 @@ namespace NzbDrone.Core.Jobs
|
||||||
|
|
||||||
logger.Info("Extracting Update package");
|
logger.Info("Extracting Update package");
|
||||||
notification.CurrentMessage = "Extracting Update";
|
notification.CurrentMessage = "Extracting Update";
|
||||||
_archiveProvider.ExtractArchive(packageDestination, _enviromentProvider.GetUpdateSandboxFolder());
|
_archiveProvider.ExtractArchive(packageDestination, _environmentProvider.GetUpdateSandboxFolder());
|
||||||
logger.Info("Update package extracted successfully");
|
logger.Info("Update package extracted successfully");
|
||||||
|
|
||||||
logger.Info("Preparing client");
|
logger.Info("Preparing client");
|
||||||
notification.CurrentMessage = "Preparing to start Update";
|
notification.CurrentMessage = "Preparing to start Update";
|
||||||
_diskProvider.MoveDirectory(_enviromentProvider.GetUpdateClientFolder(), _enviromentProvider.GetUpdateSandboxFolder());
|
_diskProvider.MoveDirectory(_environmentProvider.GetUpdateClientFolder(), _environmentProvider.GetUpdateSandboxFolder());
|
||||||
|
|
||||||
|
|
||||||
logger.Info("Starting update client");
|
logger.Info("Starting update client");
|
||||||
var startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = _enviromentProvider.GetUpdateClientExePath(),
|
FileName = _environmentProvider.GetUpdateClientExePath(),
|
||||||
Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
|
Arguments = string.Format("{0} {1}", _environmentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
|
||||||
};
|
};
|
||||||
|
|
||||||
var process = _processProvider.Start(startInfo);
|
var process = _processProvider.Start(startInfo);
|
||||||
|
|
|
@ -37,10 +37,10 @@ namespace NzbDrone.Core.Providers
|
||||||
if (!IsOnMasterBranch())
|
if (!IsOnMasterBranch())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (EnviromentProvider.RegisterNewInstall)
|
if (EnvironmentProvider.RegisterNewInstall)
|
||||||
{
|
{
|
||||||
_deskMetricsClient.RegisterInstall();
|
_deskMetricsClient.RegisterInstall();
|
||||||
EnviromentProvider.RegisterNewInstall = false;
|
EnvironmentProvider.RegisterNewInstall = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_deskMetricsClient.Started)
|
if (_deskMetricsClient.Started)
|
||||||
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Providers
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!EnviromentProvider.IsProduction)
|
if (!EnvironmentProvider.IsProduction)
|
||||||
throw;
|
throw;
|
||||||
|
|
||||||
logger.WarnException("Error while sending analytics data.", e);
|
logger.WarnException("Error while sending analytics data.", e);
|
||||||
|
|
|
@ -9,13 +9,13 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
public class BackupProvider
|
public class BackupProvider
|
||||||
{
|
{
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public BackupProvider(EnviromentProvider enviromentProvider)
|
public BackupProvider(EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackupProvider()
|
public BackupProvider()
|
||||||
|
@ -25,9 +25,9 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual string CreateBackupZip()
|
public virtual string CreateBackupZip()
|
||||||
{
|
{
|
||||||
var dbFile = _enviromentProvider.GetNzbDronoeDbFile();
|
var dbFile = _environmentProvider.GetNzbDronoeDbFile();
|
||||||
var configFile = _enviromentProvider.GetConfigPath();
|
var configFile = _environmentProvider.GetConfigPath();
|
||||||
var zipFile = _enviromentProvider.GetConfigBackupFile();
|
var zipFile = _environmentProvider.GetConfigBackupFile();
|
||||||
|
|
||||||
using (var zip = new ZipFile())
|
using (var zip = new ZipFile())
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,17 +13,17 @@ namespace NzbDrone.Core.Providers
|
||||||
public class BannerProvider
|
public class BannerProvider
|
||||||
{
|
{
|
||||||
private readonly HttpProvider _httpProvider;
|
private readonly HttpProvider _httpProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private const string BANNER_URL_PREFIX = "http://www.thetvdb.com/banners/";
|
private const string BANNER_URL_PREFIX = "http://www.thetvdb.com/banners/";
|
||||||
|
|
||||||
public BannerProvider(HttpProvider httpProvider, EnviromentProvider enviromentProvider,
|
public BannerProvider(HttpProvider httpProvider, EnvironmentProvider environmentProvider,
|
||||||
DiskProvider diskProvider)
|
DiskProvider diskProvider)
|
||||||
{
|
{
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual bool Download(ProgressNotification notification, Series series)
|
public virtual bool Download(ProgressNotification notification, Series series)
|
||||||
{
|
{
|
||||||
var bannerPath = _enviromentProvider.GetBannerPath();
|
var bannerPath = _environmentProvider.GetBannerPath();
|
||||||
|
|
||||||
logger.Trace("Ensuring Banner Folder exists: ", bannerPath);
|
logger.Trace("Ensuring Banner Folder exists: ", bannerPath);
|
||||||
_diskProvider.CreateDirectory(bannerPath);
|
_diskProvider.CreateDirectory(bannerPath);
|
||||||
|
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual bool Delete(int seriesId)
|
public virtual bool Delete(int seriesId)
|
||||||
{
|
{
|
||||||
var bannerPath = _enviromentProvider.GetBannerPath();
|
var bannerPath = _environmentProvider.GetBannerPath();
|
||||||
var bannerFilename = Path.Combine(bannerPath, seriesId.ToString()) + ".jpg";
|
var bannerFilename = Path.Combine(bannerPath, seriesId.ToString()) + ".jpg";
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -13,17 +13,17 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
public class TvDbProvider
|
public class TvDbProvider
|
||||||
{
|
{
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private const string TVDB_APIKEY = "5D2D188E86E07F4F";
|
private const string TVDB_APIKEY = "5D2D188E86E07F4F";
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly TvdbHandler _handler;
|
private readonly TvdbHandler _handler;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public TvDbProvider(EnviromentProvider enviromentProvider)
|
public TvDbProvider(EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_handler = new TvdbHandler(new XmlCacheProvider(_enviromentProvider.GetCacheFolder()), TVDB_APIKEY);
|
_handler = new TvdbHandler(new XmlCacheProvider(_environmentProvider.GetCacheFolder()), TVDB_APIKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TvDbProvider()
|
public TvDbProvider()
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
private readonly HttpProvider _httpProvider;
|
private readonly HttpProvider _httpProvider;
|
||||||
private readonly ConfigProvider _configProvider;
|
private readonly ConfigProvider _configProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
@ -29,11 +29,11 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
|
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
|
||||||
EnviromentProvider enviromentProvider, DiskProvider diskProvider)
|
EnvironmentProvider environmentProvider, DiskProvider diskProvider)
|
||||||
{
|
{
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
_configProvider = configProvider;
|
_configProvider = configProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ namespace NzbDrone.Core.Providers
|
||||||
var list = new Dictionary<DateTime, string>();
|
var list = new Dictionary<DateTime, string>();
|
||||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||||
|
|
||||||
if (_diskProvider.FolderExists(_enviromentProvider.GetUpdateLogFolder()))
|
if (_diskProvider.FolderExists(_environmentProvider.GetUpdateLogFolder()))
|
||||||
{
|
{
|
||||||
var files = _diskProvider.GetFiles(_enviromentProvider.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly).ToList();
|
var files = _diskProvider.GetFiles(_environmentProvider.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly).ToList();
|
||||||
|
|
||||||
foreach (var file in files.Select(c => new FileInfo(c)).OrderByDescending(c => c.Name))
|
foreach (var file in files.Select(c => new FileInfo(c)).OrderByDescending(c => c.Name))
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,8 +15,8 @@ namespace NzbDrone.Services.Service.App_Start
|
||||||
|
|
||||||
public static void PreStart()
|
public static void PreStart()
|
||||||
{
|
{
|
||||||
string logPath = string.Format("C:\\NLog\\{0}\\{1}\\${{shortdate}}-${{logger}}.log", HostingEnvironment.SiteName, new EnviromentProvider().Version);
|
string logPath = string.Format("C:\\NLog\\{0}\\{1}\\${{shortdate}}-${{logger}}.log", HostingEnvironment.SiteName, new EnvironmentProvider().Version);
|
||||||
string error = string.Format("C:\\NLog\\{0}\\{1}\\${{shortdate}}_Error.log", HostingEnvironment.SiteName, new EnviromentProvider().Version);
|
string error = string.Format("C:\\NLog\\{0}\\{1}\\${{shortdate}}_Error.log", HostingEnvironment.SiteName, new EnvironmentProvider().Version);
|
||||||
|
|
||||||
LogConfiguration.RegisterUdpLogger();
|
LogConfiguration.RegisterUdpLogger();
|
||||||
LogConfiguration.RegisterFileLogger(logPath, LogLevel.Trace);
|
LogConfiguration.RegisterFileLogger(logPath, LogLevel.Trace);
|
||||||
|
|
|
@ -9,12 +9,12 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
{
|
{
|
||||||
public class HealthController : Controller
|
public class HealthController : Controller
|
||||||
{
|
{
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
|
|
||||||
public HealthController(EnviromentProvider enviromentProvider, IDatabase database)
|
public HealthController(EnvironmentProvider environmentProvider, IDatabase database)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_database = database;
|
_database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
{
|
{
|
||||||
var stat = new
|
var stat = new
|
||||||
{
|
{
|
||||||
Service = _enviromentProvider.Version.ToString(),
|
Service = _environmentProvider.Version.ToString(),
|
||||||
Schema = _database.Fetch<SchemaInfo>().OrderByDescending(c => c.Version).First()
|
Schema = _database.Fetch<SchemaInfo>().OrderByDescending(c => c.Version).First()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Services.Service.Helpers
|
||||||
|
|
||||||
static HtmlIncludeExtentions()
|
static HtmlIncludeExtentions()
|
||||||
{
|
{
|
||||||
versionString = new EnviromentProvider().Version.ToString().Replace('.', '_');
|
versionString = new EnvironmentProvider().Version.ToString().Replace('.', '_');
|
||||||
isProduction = true;
|
isProduction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace NzbDrone.Test.Common
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void TestBaseSetup()
|
public void TestBaseSetup()
|
||||||
{
|
{
|
||||||
EnviromentProvider.RegisterNewInstall = true;
|
EnvironmentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
MockedRestProvider = new Mock<RestProvider>();
|
MockedRestProvider = new Mock<RestProvider>();
|
||||||
ReportingService.RestProvider = MockedRestProvider.Object;
|
ReportingService.RestProvider = MockedRestProvider.Object;
|
||||||
|
@ -75,7 +75,7 @@ namespace NzbDrone.Test.Common
|
||||||
|
|
||||||
protected void WithTempAsAppPath()
|
protected void WithTempAsAppPath()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<EnviromentProvider>()
|
Mocker.GetMock<EnvironmentProvider>()
|
||||||
.SetupGet(c => c.ApplicationPath)
|
.SetupGet(c => c.ApplicationPath)
|
||||||
.Returns(VirtualPath);
|
.Returns(VirtualPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,16 @@ namespace NzbDrone.Update.Test
|
||||||
private const string TARGET_FOLDER = @"C:\NzbDrone\";
|
private const string TARGET_FOLDER = @"C:\NzbDrone\";
|
||||||
private const string UPDATE_LOG_FOLDER = @"C:\NzbDrone\UpdateLogs\";
|
private const string UPDATE_LOG_FOLDER = @"C:\NzbDrone\UpdateLogs\";
|
||||||
|
|
||||||
Mock<EnviromentProvider> _enviromentProvider;
|
Mock<EnvironmentProvider> _environmentProvider;
|
||||||
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
_enviromentProvider = Mocker.GetMock<EnviromentProvider>();
|
_environmentProvider = Mocker.GetMock<EnvironmentProvider>();
|
||||||
|
|
||||||
_enviromentProvider.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
_environmentProvider.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||||
|
|
||||||
Mocker.GetMock<DiskProvider>()
|
Mocker.GetMock<DiskProvider>()
|
||||||
.Setup(c => c.FolderExists(UPDATE_FOLDER))
|
.Setup(c => c.FolderExists(UPDATE_FOLDER))
|
||||||
|
|
|
@ -18,10 +18,10 @@ namespace NzbDrone.Update.Test
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<EnviromentProvider>()
|
Mocker.GetMock<EnvironmentProvider>()
|
||||||
.Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\");
|
.Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\");
|
||||||
|
|
||||||
Mocker.GetMock<EnviromentProvider>()
|
Mocker.GetMock<EnvironmentProvider>()
|
||||||
.Setup(c => c.SystemTemp).Returns(@"C:\Temp\");
|
.Setup(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace NzbDrone.Update
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.Info("Updating NzbDrone to version {0}", _kernel.Get<EnviromentProvider>().Version);
|
logger.Info("Updating NzbDrone to version {0}", _kernel.Get<EnvironmentProvider>().Version);
|
||||||
_kernel.Get<Program>().Start(args);
|
_kernel.Get<Program>().Start(args);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -48,10 +48,10 @@ namespace NzbDrone.Update
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var enviromentProvider = _kernel.Get<EnviromentProvider>();
|
var environmentProvider = _kernel.Get<EnvironmentProvider>();
|
||||||
var diskProvider = _kernel.Get<DiskProvider>();
|
var diskProvider = _kernel.Get<DiskProvider>();
|
||||||
logger.Info("Copying log files to application directory.");
|
logger.Info("Copying log files to application directory.");
|
||||||
diskProvider.CopyDirectory(enviromentProvider.GetSandboxLogFolder(), enviromentProvider.GetUpdateLogFolder());
|
diskProvider.CopyDirectory(environmentProvider.GetSandboxLogFolder(), environmentProvider.GetUpdateLogFolder());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Update
|
||||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
|
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
|
||||||
LogConfiguration.RegisterUdpLogger();
|
LogConfiguration.RegisterUdpLogger();
|
||||||
|
|
||||||
var logPath = Path.Combine(new EnviromentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
|
var logPath = Path.Combine(new EnvironmentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
|
||||||
LogConfiguration.RegisterFileLogger(logPath, LogLevel.Info);
|
LogConfiguration.RegisterFileLogger(logPath, LogLevel.Info);
|
||||||
|
|
||||||
LogConfiguration.Reload();
|
LogConfiguration.Reload();
|
||||||
|
|
|
@ -12,17 +12,17 @@ namespace NzbDrone.Update.Providers
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private readonly ServiceProvider _serviceProvider;
|
private readonly ServiceProvider _serviceProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly IISProvider _iisProvider;
|
private readonly IISProvider _iisProvider;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public UpdateProvider(DiskProvider diskProvider, ServiceProvider serviceProvider,
|
public UpdateProvider(DiskProvider diskProvider, ServiceProvider serviceProvider,
|
||||||
ProcessProvider processProvider, EnviromentProvider enviromentProvider, IISProvider iisProvider)
|
ProcessProvider processProvider, EnvironmentProvider environmentProvider, IISProvider iisProvider)
|
||||||
{
|
{
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_iisProvider = iisProvider;
|
_iisProvider = iisProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ namespace NzbDrone.Update.Providers
|
||||||
throw new DirectoryNotFoundException("Target folder doesn't exist " + targetFolder);
|
throw new DirectoryNotFoundException("Target folder doesn't exist " + targetFolder);
|
||||||
|
|
||||||
logger.Info("Verifying Update Folder");
|
logger.Info("Verifying Update Folder");
|
||||||
if (!_diskProvider.FolderExists(_enviromentProvider.GetUpdatePackageFolder()))
|
if (!_diskProvider.FolderExists(_environmentProvider.GetUpdatePackageFolder()))
|
||||||
throw new DirectoryNotFoundException("Update folder doesn't exist " + _enviromentProvider.GetUpdatePackageFolder());
|
throw new DirectoryNotFoundException("Update folder doesn't exist " + _environmentProvider.GetUpdatePackageFolder());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@ namespace NzbDrone.Update.Providers
|
||||||
_iisProvider.StopServer();
|
_iisProvider.StopServer();
|
||||||
|
|
||||||
logger.Info("Creating backup of existing installation");
|
logger.Info("Creating backup of existing installation");
|
||||||
_diskProvider.CopyDirectory(targetFolder, _enviromentProvider.GetUpdateBackUpFolder());
|
_diskProvider.CopyDirectory(targetFolder, _environmentProvider.GetUpdateBackUpFolder());
|
||||||
|
|
||||||
|
|
||||||
logger.Info("Moving update package to target");
|
logger.Info("Moving update package to target");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_diskProvider.CopyDirectory(_enviromentProvider.GetUpdatePackageFolder(), targetFolder);
|
_diskProvider.CopyDirectory(_environmentProvider.GetUpdatePackageFolder(), targetFolder);
|
||||||
|
|
||||||
logger.Trace("Deleting Update Package.");
|
logger.Trace("Deleting Update Package.");
|
||||||
_diskProvider.DeleteFolder(_enviromentProvider.GetUpdatePackageFolder(), true);
|
_diskProvider.DeleteFolder(_environmentProvider.GetUpdatePackageFolder(), true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Update.Providers
|
||||||
{
|
{
|
||||||
//TODO:this should ignore single file failures.
|
//TODO:this should ignore single file failures.
|
||||||
logger.Info("Attempting to rollback upgrade");
|
logger.Info("Attempting to rollback upgrade");
|
||||||
_diskProvider.CopyDirectory(_enviromentProvider.GetUpdateBackUpFolder(), targetFolder);
|
_diskProvider.CopyDirectory(_environmentProvider.GetUpdateBackUpFolder(), targetFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Web.UI.Automation
|
||||||
[TestFixture(Category = "Automation")]
|
[TestFixture(Category = "Automation")]
|
||||||
public abstract class AutomationTestBase
|
public abstract class AutomationTestBase
|
||||||
{
|
{
|
||||||
private static readonly EnviromentProvider enviromentProvider = new EnviromentProvider();
|
private static readonly EnvironmentProvider environmentProvider = new EnvironmentProvider();
|
||||||
|
|
||||||
private readonly string _clonePackagePath;
|
private readonly string _clonePackagePath;
|
||||||
private readonly string _masterPackagePath;
|
private readonly string _masterPackagePath;
|
||||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Web.UI.Automation
|
||||||
|
|
||||||
protected AutomationTestBase()
|
protected AutomationTestBase()
|
||||||
{
|
{
|
||||||
var rawPackagePath = Path.Combine(enviromentProvider.ApplicationPath, "_rawPackage");
|
var rawPackagePath = Path.Combine(environmentProvider.ApplicationPath, "_rawPackage");
|
||||||
_clonePackagePath = Path.Combine(rawPackagePath, "NzbDrone_Automation");
|
_clonePackagePath = Path.Combine(rawPackagePath, "NzbDrone_Automation");
|
||||||
_masterPackagePath = Path.Combine(rawPackagePath, "NzbDrone");
|
_masterPackagePath = Path.Combine(rawPackagePath, "NzbDrone");
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ namespace NzbDrone.Web.UI.Automation
|
||||||
|
|
||||||
StopNzbDrone();
|
StopNzbDrone();
|
||||||
|
|
||||||
var rootDirectory = new DirectoryInfo(enviromentProvider.ApplicationPath);
|
var rootDirectory = new DirectoryInfo(environmentProvider.ApplicationPath);
|
||||||
|
|
||||||
if (rootDirectory.GetDirectories("_rawPackage").Any())
|
if (rootDirectory.GetDirectories("_rawPackage").Any())
|
||||||
{
|
{
|
||||||
|
@ -212,7 +212,7 @@ namespace NzbDrone.Web.UI.Automation
|
||||||
|
|
||||||
Process.Start(startInfo).WaitForExit();
|
Process.Start(startInfo).WaitForExit();
|
||||||
|
|
||||||
var testFolder = Path.Combine(enviromentProvider.SystemTemp, "NzbDroneAutomation");
|
var testFolder = Path.Combine(environmentProvider.SystemTemp, "NzbDroneAutomation");
|
||||||
|
|
||||||
if (Directory.Exists(testFolder))
|
if (Directory.Exists(testFolder))
|
||||||
{
|
{
|
||||||
|
@ -239,12 +239,12 @@ namespace NzbDrone.Web.UI.Automation
|
||||||
{
|
{
|
||||||
var folderName = "Debug";
|
var folderName = "Debug";
|
||||||
|
|
||||||
if (EnviromentProvider.IsDebug)
|
if (EnvironmentProvider.IsDebug)
|
||||||
{
|
{
|
||||||
folderName = "Release";
|
folderName = "Release";
|
||||||
}
|
}
|
||||||
|
|
||||||
var dirs = Directory.GetDirectories(enviromentProvider.ApplicationPath, folderName, SearchOption.AllDirectories);
|
var dirs = Directory.GetDirectories(environmentProvider.ApplicationPath, folderName, SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
|
||||||
foreach (var dir in dirs)
|
foreach (var dir in dirs)
|
||||||
|
|
|
@ -13,15 +13,15 @@ namespace NzbDrone.Web.App_Start
|
||||||
{
|
{
|
||||||
public static void PreStart()
|
public static void PreStart()
|
||||||
{
|
{
|
||||||
var enviromentProvider = new EnviromentProvider();
|
var environmentProvider = new EnvironmentProvider();
|
||||||
|
|
||||||
LogManager.Configuration = new XmlLoggingConfiguration(enviromentProvider.GetNlogConfigPath(), false);
|
LogManager.Configuration = new XmlLoggingConfiguration(environmentProvider.GetNlogConfigPath(), false);
|
||||||
|
|
||||||
LogConfiguration.RegisterUdpLogger();
|
LogConfiguration.RegisterUdpLogger();
|
||||||
LogConfiguration.RegisterRemote();
|
LogConfiguration.RegisterRemote();
|
||||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
|
LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
|
||||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
|
LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
|
||||||
LogConfiguration.RegisterRollingFileLogger(enviromentProvider.GetLogFileName(), LogLevel.Trace);
|
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Trace);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace NzbDrone.Web.App_Start
|
||||||
// so authenticated users are always profiled
|
// so authenticated users are always profiled
|
||||||
//if (request.IsLocal) { MiniProfiler.Start(); }
|
//if (request.IsLocal) { MiniProfiler.Start(); }
|
||||||
|
|
||||||
if (!EnviromentProvider.IsProduction || ProfilerHelper.Enabled())
|
if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
|
||||||
{
|
{
|
||||||
var requestPath = ((HttpApplication)sender).Request.AppRelativeCurrentExecutionFilePath.ToLower();
|
var requestPath = ((HttpApplication)sender).Request.AppRelativeCurrentExecutionFilePath.ToLower();
|
||||||
if (!requestPath.StartsWith("~/signalr") && !requestPath.EndsWith("notification/comet"))
|
if (!requestPath.StartsWith("~/signalr") && !requestPath.EndsWith("notification/comet"))
|
||||||
|
|
|
@ -13,13 +13,13 @@ namespace NzbDrone.Web.Controllers
|
||||||
public class LogController : Controller
|
public class LogController : Controller
|
||||||
{
|
{
|
||||||
private readonly LogProvider _logProvider;
|
private readonly LogProvider _logProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
|
|
||||||
public LogController(LogProvider logProvider, EnviromentProvider enviromentProvider, DiskProvider diskProvider)
|
public LogController(LogProvider logProvider, EnvironmentProvider environmentProvider, DiskProvider diskProvider)
|
||||||
{
|
{
|
||||||
_logProvider = logProvider;
|
_logProvider = logProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ namespace NzbDrone.Web.Controllers
|
||||||
{
|
{
|
||||||
string log = string.Empty;
|
string log = string.Empty;
|
||||||
|
|
||||||
if (_diskProvider.FileExists(_enviromentProvider.GetArchivedLogFileName()))
|
if (_diskProvider.FileExists(_environmentProvider.GetArchivedLogFileName()))
|
||||||
{
|
{
|
||||||
log = _diskProvider.ReadAllText(_enviromentProvider.GetArchivedLogFileName());
|
log = _diskProvider.ReadAllText(_environmentProvider.GetArchivedLogFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
log += _diskProvider.ReadAllText(_enviromentProvider.GetLogFileName());
|
log += _diskProvider.ReadAllText(_environmentProvider.GetLogFileName());
|
||||||
|
|
||||||
return new FileContentResult(Encoding.ASCII.GetBytes(log), "text/plain");
|
return new FileContentResult(Encoding.ASCII.GetBytes(log), "text/plain");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ namespace NzbDrone.Web.Controllers
|
||||||
{
|
{
|
||||||
public class SharedController : Controller
|
public class SharedController : Controller
|
||||||
{
|
{
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
public SharedController(EnviromentProvider enviromentProvider)
|
public SharedController(EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
|
@ -22,7 +22,7 @@ namespace NzbDrone.Web.Controllers
|
||||||
[OutputCache(Duration = 3600)]
|
[OutputCache(Duration = 3600)]
|
||||||
public ActionResult Footer()
|
public ActionResult Footer()
|
||||||
{
|
{
|
||||||
return PartialView(new FooterModel { BuildTime = _enviromentProvider.BuildDateTime, Version = _enviromentProvider.Version });
|
return PartialView(new FooterModel { BuildTime = _environmentProvider.BuildDateTime, Version = _environmentProvider.Version });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,24 +12,24 @@ namespace NzbDrone.Web.Controllers
|
||||||
{
|
{
|
||||||
private readonly UpdateProvider _updateProvider;
|
private readonly UpdateProvider _updateProvider;
|
||||||
private readonly JobProvider _jobProvider;
|
private readonly JobProvider _jobProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
|
|
||||||
public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider,
|
public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider,
|
||||||
EnviromentProvider enviromentProvider, DiskProvider diskProvider)
|
EnvironmentProvider environmentProvider, DiskProvider diskProvider)
|
||||||
{
|
{
|
||||||
_updateProvider = updateProvider;
|
_updateProvider = updateProvider;
|
||||||
_jobProvider = jobProvider;
|
_jobProvider = jobProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
var updateModel = new UpdateModel();
|
var updateModel = new UpdateModel();
|
||||||
updateModel.UpdatePackage = _updateProvider.GetAvilableUpdate(_enviromentProvider.Version);
|
updateModel.UpdatePackage = _updateProvider.GetAvilableUpdate(_environmentProvider.Version);
|
||||||
updateModel.LogFiles = _updateProvider.UpdateLogFile();
|
updateModel.LogFiles = _updateProvider.UpdateLogFile();
|
||||||
updateModel.LogFolder = _enviromentProvider.GetUpdateLogFolder();
|
updateModel.LogFolder = _environmentProvider.GetUpdateLogFolder();
|
||||||
|
|
||||||
return View(updateModel);
|
return View(updateModel);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace NzbDrone.Web.Controllers
|
||||||
public ActionResult Post(string expectedVersion)
|
public ActionResult Post(string expectedVersion)
|
||||||
{
|
{
|
||||||
var model = new PostUpgradeModel();
|
var model = new PostUpgradeModel();
|
||||||
model.CurrentVersion = _enviromentProvider.Version;
|
model.CurrentVersion = _environmentProvider.Version;
|
||||||
model.ExpectedVersion = Version.Parse(expectedVersion);
|
model.ExpectedVersion = Version.Parse(expectedVersion);
|
||||||
model.Success = model.CurrentVersion >= model.ExpectedVersion;
|
model.Success = model.CurrentVersion >= model.ExpectedVersion;
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ namespace NzbDrone.Web.Helpers
|
||||||
|
|
||||||
static HtmlIncludeExtentions()
|
static HtmlIncludeExtentions()
|
||||||
{
|
{
|
||||||
versionString = new EnviromentProvider().Version.ToString().Replace('.', '_');
|
versionString = new EnvironmentProvider().Version.ToString().Replace('.', '_');
|
||||||
isProduction = EnviromentProvider.IsProduction;
|
isProduction = EnvironmentProvider.IsProduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MvcHtmlString IncludeScript(this HtmlHelper helper, string filename)
|
public static MvcHtmlString IncludeScript(this HtmlHelper helper, string filename)
|
||||||
|
|
|
@ -10,8 +10,8 @@ namespace NzbDrone.Web.Helpers
|
||||||
{
|
{
|
||||||
public static bool Enabled()
|
public static bool Enabled()
|
||||||
{
|
{
|
||||||
var enviromentProvider = new EnviromentProvider();
|
var environmentProvider = new EnvironmentProvider();
|
||||||
var configFileProvider = new ConfigFileProvider(enviromentProvider);
|
var configFileProvider = new ConfigFileProvider(environmentProvider);
|
||||||
|
|
||||||
return configFileProvider.EnableProfiler;
|
return configFileProvider.EnableProfiler;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title);
|
ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title);
|
||||||
}
|
}
|
||||||
<title>@ViewBag.Title</title>
|
<title>@ViewBag.Title</title>
|
||||||
@if (!EnviromentProvider.IsProduction || ProfilerHelper.Enabled())
|
@if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
|
||||||
{
|
{
|
||||||
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
|
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
@RenderSection("Scripts", required: false)
|
@RenderSection("Scripts", required: false)
|
||||||
@Html.IncludeScript("jquery.signalR.min.js")
|
@Html.IncludeScript("jquery.signalR.min.js")
|
||||||
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
|
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
|
||||||
@if (EnviromentProvider.IsProduction)
|
@if (EnvironmentProvider.IsProduction)
|
||||||
{
|
{
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone
|
||||||
|
|
||||||
private readonly ConfigFileProvider _configFileProvider;
|
private readonly ConfigFileProvider _configFileProvider;
|
||||||
private readonly DebuggerProvider _debuggerProvider;
|
private readonly DebuggerProvider _debuggerProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private readonly IISProvider _iisProvider;
|
private readonly IISProvider _iisProvider;
|
||||||
private readonly ProcessProvider _processProvider;
|
private readonly ProcessProvider _processProvider;
|
||||||
private readonly MonitoringProvider _monitoringProvider;
|
private readonly MonitoringProvider _monitoringProvider;
|
||||||
|
@ -22,13 +22,13 @@ namespace NzbDrone
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public ApplicationServer(ConfigFileProvider configFileProvider, IISProvider iisProvider,
|
public ApplicationServer(ConfigFileProvider configFileProvider, IISProvider iisProvider,
|
||||||
DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider,
|
DebuggerProvider debuggerProvider, EnvironmentProvider environmentProvider,
|
||||||
ProcessProvider processProvider, MonitoringProvider monitoringProvider, SecurityProvider securityProvider)
|
ProcessProvider processProvider, MonitoringProvider monitoringProvider, SecurityProvider securityProvider)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
_iisProvider = iisProvider;
|
_iisProvider = iisProvider;
|
||||||
_debuggerProvider = debuggerProvider;
|
_debuggerProvider = debuggerProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
_monitoringProvider = monitoringProvider;
|
_monitoringProvider = monitoringProvider;
|
||||||
_securityProvider = securityProvider;
|
_securityProvider = securityProvider;
|
||||||
|
@ -52,7 +52,7 @@ namespace NzbDrone
|
||||||
|
|
||||||
_debuggerProvider.Attach();
|
_debuggerProvider.Attach();
|
||||||
|
|
||||||
if (_enviromentProvider.IsUserInteractive && _configFileProvider.LaunchBrowser)
|
if (_environmentProvider.IsUserInteractive && _configFileProvider.LaunchBrowser)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace NzbDrone
|
||||||
_kernel.Bind<ConfigFileProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<ConfigFileProvider>().ToSelf().InSingletonScope();
|
||||||
_kernel.Bind<ConsoleProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<ConsoleProvider>().ToSelf().InSingletonScope();
|
||||||
_kernel.Bind<DebuggerProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<DebuggerProvider>().ToSelf().InSingletonScope();
|
||||||
_kernel.Bind<EnviromentProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<EnvironmentProvider>().ToSelf().InSingletonScope();
|
||||||
_kernel.Bind<IISProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<IISProvider>().ToSelf().InSingletonScope();
|
||||||
_kernel.Bind<MonitoringProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<MonitoringProvider>().ToSelf().InSingletonScope();
|
||||||
_kernel.Bind<ProcessProvider>().ToSelf().InSingletonScope();
|
_kernel.Bind<ProcessProvider>().ToSelf().InSingletonScope();
|
||||||
|
@ -43,16 +43,16 @@ namespace NzbDrone
|
||||||
|
|
||||||
private static void InitilizeApp()
|
private static void InitilizeApp()
|
||||||
{
|
{
|
||||||
var enviromentProvider = _kernel.Get<EnviromentProvider>();
|
var environmentProvider = _kernel.Get<EnvironmentProvider>();
|
||||||
|
|
||||||
ReportingService.RestProvider = _kernel.Get<RestProvider>();
|
ReportingService.RestProvider = _kernel.Get<RestProvider>();
|
||||||
|
|
||||||
LogConfiguration.RegisterRollingFileLogger(enviromentProvider.GetLogFileName(), LogLevel.Info);
|
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
|
||||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
|
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
|
||||||
LogConfiguration.RegisterUdpLogger();
|
LogConfiguration.RegisterUdpLogger();
|
||||||
LogConfiguration.RegisterRemote();
|
LogConfiguration.RegisterRemote();
|
||||||
LogConfiguration.Reload();
|
LogConfiguration.Reload();
|
||||||
Logger.Info("Start-up Path:'{0}'", enviromentProvider.ApplicationPath);
|
Logger.Info("Start-up Path:'{0}'", environmentProvider.ApplicationPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace NzbDrone.Providers
|
||||||
{
|
{
|
||||||
Console.WriteLine("EPIC FAIL: {0}", excepion);
|
Console.WriteLine("EPIC FAIL: {0}", excepion);
|
||||||
|
|
||||||
if (EnviromentProvider.IsProduction)
|
if (EnvironmentProvider.IsProduction)
|
||||||
{
|
{
|
||||||
new Client
|
new Client
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,14 +14,14 @@ namespace NzbDrone
|
||||||
private readonly ApplicationServer _applicationServer;
|
private readonly ApplicationServer _applicationServer;
|
||||||
private readonly ServiceProvider _serviceProvider;
|
private readonly ServiceProvider _serviceProvider;
|
||||||
private readonly ConsoleProvider _consoleProvider;
|
private readonly ConsoleProvider _consoleProvider;
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
|
|
||||||
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider, EnviromentProvider enviromentProvider)
|
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
_applicationServer = applicationServer;
|
_applicationServer = applicationServer;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_consoleProvider = consoleProvider;
|
_consoleProvider = consoleProvider;
|
||||||
_enviromentProvider = enviromentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Route(IEnumerable<string> args)
|
public void Route(IEnumerable<string> args)
|
||||||
|
@ -35,7 +35,7 @@ namespace NzbDrone
|
||||||
logger.Info("Application mode: {0}", applicationMode);
|
logger.Info("Application mode: {0}", applicationMode);
|
||||||
|
|
||||||
//TODO:move this outside, it should be one of application modes (ApplicationMode.Service?)
|
//TODO:move this outside, it should be one of application modes (ApplicationMode.Service?)
|
||||||
if (!_enviromentProvider.IsUserInteractive)
|
if (!_environmentProvider.IsUserInteractive)
|
||||||
{
|
{
|
||||||
_serviceProvider.Run(_applicationServer);
|
_serviceProvider.Run(_applicationServer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue