Merge branch 'kay.one' of github.com:NzbDrone/NzbDrone into markus

pull/2/head
Mark McDowall 13 years ago
commit d5a602c4eb

@ -0,0 +1,64 @@
using System;
using System.Diagnostics;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Common.Model;
using NzbDrone.Providers;
using NzbDrone.Test.Common;
using NzbDrone.Test.Dummy;
namespace NzbDrone.App.Test
{
[TestFixture]
public class IISProviderFixture : TestBase
{
[Test]
public void should_update_pid_env_varibles()
{
WithTempAsAppPath();
var dummy = StartDummyProcess();
Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PID, "0");
Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PATH, "Test");
Mocker.GetMock<ProcessProvider>()
.Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
.Returns(dummy);
Mocker.Resolve<IISProvider>().StartServer();
}
[Test]
public void should_set_iis_procces_id()
{
WithTempAsAppPath();
var dummy = StartDummyProcess();
Mocker.GetMock<ProcessProvider>()
.Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
.Returns(dummy);
//act
Mocker.Resolve<IISProvider>().StartServer();
//assert
Mocker.Resolve<IISProvider>().IISProcessId.Should().Be(dummy.Id);
}
public Process StartDummyProcess()
{
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
return new ProcessProvider().Start(startInfo);
}
}
}

@ -30,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="FizzWare.NBuilder">
@ -65,6 +66,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CentralDispatchTests.cs" />
<Compile Include="IISProviderFixture.cs" />
<Compile Include="RouterTest.cs" />
<Compile Include="MonitoringProviderTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -35,11 +35,7 @@ namespace NzbDrone.Common.Test
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
//Assert
BinFolder.Refresh();
BinFolderCopy.Refresh();
BinFolder.GetFiles("*.*", SearchOption.AllDirectories)
.Should().HaveSameCount(BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories));
VerifyCopy();
}
[Test]
@ -51,16 +47,24 @@ namespace NzbDrone.Common.Test
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
//Delete Random File
BinFolderCopy.GetFiles().First().Delete();
BinFolderCopy.Refresh();
BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
//Assert
VerifyCopy();
}
private void VerifyCopy()
{
BinFolder.Refresh();
BinFolderCopy.Refresh();
BinFolder.GetFiles("*.*", SearchOption.AllDirectories)
.Should().HaveSameCount(BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories));
BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories)
.Should().HaveSameCount(BinFolder.GetFiles("*.*", SearchOption.AllDirectories));
BinFolderCopy.GetDirectories().Should().HaveSameCount(BinFolder.GetDirectories());
}
}
}

@ -30,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=1.6.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">

@ -13,8 +13,11 @@ namespace NzbDrone.Common.Test
private EnviromentProvider GetEnviromentProvider()
{
var envMoq = new Mock<EnviromentProvider>();
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
envMoq.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
return envMoq.Object;
}
@ -49,5 +52,29 @@ namespace NzbDrone.Common.Test
{
GetEnviromentProvider().GetNlogConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\log.config");
}
[Test]
public void Sanbox()
{
GetEnviromentProvider().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\");
}
[Test]
public void GetUpdatePackageFolder()
{
GetEnviromentProvider().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\");
}
[Test]
public void GetUpdateClientFolder()
{
GetEnviromentProvider().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\");
}
[Test]
public void GetUpdateClientExePath()
{
GetEnviromentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\NzbDrone.Update.exe");
}
}
}

@ -4,26 +4,27 @@ using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Dummy;
namespace NzbDrone.Common.Test
{
[TestFixture]
public class ProcessProviderTests : TestBase
{
private const string DummyProccessName = "NzbDrone.Test.Dummy";
ProcessProvider _processProvider;
[SetUp]
public void Setup()
{
Process.GetProcessesByName(DummyProccessName).ToList().ForEach(c => c.Kill());
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c => c.Kill());
_processProvider = new ProcessProvider();
}
[TearDown]
public void TearDown()
{
Process.GetProcessesByName(DummyProccessName).ToList().ForEach(c => c.Kill());
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c => c.Kill());
}
[TestCase(0)]
@ -58,20 +59,20 @@ namespace NzbDrone.Common.Test
[Test]
public void Should_be_able_to_start_process()
{
var startInfo = new ProcessStartInfo(DummyProccessName + ".exe");
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
//Act/Assert
_processProvider.GetProcessByName(DummyProccessName).Should()
_processProvider.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
.BeEmpty("Dummy process is already running");
_processProvider.Start(startInfo).Should().NotBeNull();
_processProvider.GetProcessByName(DummyProccessName).Should()
_processProvider.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
.HaveCount(1, "excepted one dummy process to be already running");
}
public Process StartDummyProcess()
{
var startInfo = new ProcessStartInfo(DummyProccessName + ".exe");
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
return _processProvider.Start(startInfo);
}

@ -4,6 +4,7 @@ using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using NLog;
using Ninject;
using NzbDrone.Common.Model;
namespace NzbDrone.Common
@ -14,6 +15,8 @@ namespace NzbDrone.Common
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly string _configFile;
[Inject]
public ConfigFileProvider(EnviromentProvider enviromentProvider)
{
_enviromentProvider = enviromentProvider;
@ -22,6 +25,11 @@ namespace NzbDrone.Common
CreateDefaultConfigFile();
}
public ConfigFileProvider()
{
}
public virtual Guid Guid
{
get

@ -67,7 +67,12 @@ namespace NzbDrone.Common
targetFolder.Create();
}
foreach (var file in sourceFolder.GetFiles("*.*", SearchOption.AllDirectories))
foreach (var subDir in sourceFolder.GetDirectories())
{
CopyDirectory(subDir.FullName, Path.Combine(target, subDir.Name));
}
foreach (var file in sourceFolder.GetFiles("*.*", SearchOption.TopDirectoryOnly))
{
var destFile = Path.Combine(target, file.Name);
file.CopyTo(destFile, true);

@ -9,6 +9,9 @@ namespace NzbDrone.Common
{
public const string IIS_FOLDER_NAME = "iisexpress";
public const string NZBDRONE_PATH = "NZBDRONE_PATH";
public const string NZBDRONE_PID = "NZBDRONE_PID";
#if DEBUG
private static readonly bool isInDebug = true;
#else
@ -98,7 +101,7 @@ namespace NzbDrone.Common
{
get
{
var id = Convert.ToInt32(Environment.GetEnvironmentVariable("NZBDRONE_PID"));
var id = Convert.ToInt32(Environment.GetEnvironmentVariable(NZBDRONE_PID));
if (id == 0)
throw new InvalidOperationException("NZBDRONE_PID isn't a valid environment variable.");

@ -50,12 +50,18 @@ namespace NzbDrone.Common
{
try
{
var udpTarget = new ChainsawTarget();
var udpTarget = new NLogViewerTarget();
udpTarget.Address = "udp://127.0.0.1:20480";
udpTarget.IncludeCallSite = true;
udpTarget.IncludeSourceInfo = true;
udpTarget.IncludeNLogData = true;
udpTarget.IncludeNdc = true;
udpTarget.Parameters.Add(new NLogViewerParameterInfo
{
Name = "Exception",
Layout = "${exception:format=ToString}"
});
LogManager.Configuration.AddTarget(udpTarget.GetType().Name, udpTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, udpTarget));
@ -68,7 +74,6 @@ namespace NzbDrone.Common
if (LogManager.ThrowExceptions)
throw;
}
}
public static void RegisterExceptioneer()

@ -30,11 +30,15 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Exceptioneer.WindowsFormsClient">
<HintPath>..\Libraries\Exceptioneer.WindowsFormsClient.dll</HintPath>
</Reference>
<Reference Include="Ninject">
<HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>

@ -20,6 +20,7 @@ namespace NzbDrone.Common
private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\";
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
private const string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update\\";
public static string GetIISFolder(this EnviromentProvider enviromentProvider)
{
@ -91,9 +92,14 @@ namespace NzbDrone.Common
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_PACKAGE_FOLDER_NAME);
}
public static string GetUpdateClientFolder(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.GetUpdatePackageFolder(), UPDATE_CLIENT_FOLDER_NAME);
}
public static string GetUpdateClientExePath(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_CLIENT_EXE);
return Path.Combine(enviromentProvider.GetUpdateClientFolder(), UPDATE_CLIENT_EXE);
}
}
}

@ -12,5 +12,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
[assembly: AssemblyVersion("0.0.0.*")]
[assembly: AssemblyFileVersion("0.0.0.*")]

@ -93,7 +93,7 @@
<Compile Include="JobTests\SearchJobTest.cs" />
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDownloadFixture.cs" />
<Compile Include="ProviderTests\JobProviderTests\TestJobs.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\PreformUpdateFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\StartUpdateFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\GetAvilableUpdateFixture.cs" />
<Compile Include="SortHelperTest.cs" />
<Compile Include="ProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />

@ -14,10 +14,12 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
[TestFixture]
internal class PreformUpdateFixture : CoreTest
internal class StartUpdateFixture : CoreTest
{
private const string SANDBOX_FOLDER = @"C:\Temp\nzbdrone_update\";
private readonly Guid _clientGuid = Guid.NewGuid();
private readonly UpdatePackage updatePackage = new UpdatePackage
{
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
@ -29,9 +31,33 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
public void Setup()
{
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
Mocker.GetMock<ConfigFileProvider>().SetupGet(c => c.Guid).Returns(_clientGuid);
}
[Test]
public void should_delete_sandbox_before_update_if_folder_exists()
{
Mocker.GetMock<DiskProvider>().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(true);
//Act
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true));
}
[Test]
public void should_not_delete_sandbox_before_update_if_folder_doesnt_exists()
{
Mocker.GetMock<DiskProvider>().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(false);
//Act
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never());
}
[Test]
public void Should_download_update_package()
@ -39,7 +65,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<HttpProvider>().Verify(
@ -47,33 +73,49 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
}
[Test]
public void Should_call_download_and_extract_using_correct_arguments()
public void Should_extract_update_package()
{
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<ArchiveProvider>().Verify(
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
}
[Test]
public void Should_copy_update_client_to_root_of_sandbox()
{
var updateClientFolder = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientFolder();
//Act
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<DiskProvider>().Verify(
c => c.CopyDirectory(updateClientFolder, SANDBOX_FOLDER));
}
[Test]
public void should_start_update_client()
{
//Setup
var updateClientPath = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientExePath();
Mocker.GetMock<EnviromentProvider>()
.SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<ProcessProvider>().Verify(
c => c.Start(It.Is<ProcessStartInfo>(p =>
c => c.Start(It.Is<ProcessStartInfo>(p =>
p.FileName == updateClientPath &&
p.Arguments == "/12 /"
)));
p.Arguments == "12 " + _clientGuid.ToString())
));
}
[Test]
@ -92,7 +134,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
Mocker.Resolve<HttpProvider>();
Mocker.Resolve<DiskProvider>();
Mocker.Resolve<ArchiveProvider>();
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
updateSubFolder.Refresh();
//Assert

@ -92,6 +92,7 @@ namespace NzbDrone.Core
Kernel.Bind<IJob>().To<BacklogSearchJob>().InSingletonScope();
Kernel.Bind<IJob>().To<BannerDownloadJob>().InSingletonScope();
Kernel.Bind<IJob>().To<ConvertEpisodeJob>().InSingletonScope();
Kernel.Bind<IJob>().To<AppUpdateJob>().InSingletonScope();
Kernel.Get<JobProvider>().Initialize();
Kernel.Get<WebTimer>().StartTimer(30);

@ -220,6 +220,7 @@
<Compile Include="Providers\Indexer\Newznab.cs" />
<Compile Include="Providers\NewznzbProvider.cs" />
<Compile Include="Providers\ExternalNotification\Prowl.cs" />
<Compile Include="Providers\Jobs\AppUpdateJob.cs" />
<Compile Include="Providers\ProwlProvider.cs" />
<Compile Include="Providers\Core\UdpProvider.cs" />
<Compile Include="Providers\ExternalNotification\Growl.cs" />

@ -16,5 +16,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
[assembly: AssemblyVersion("0.0.0.*")]
[assembly: AssemblyFileVersion("0.0.0.*")]

@ -0,0 +1,33 @@
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers.Jobs
{
public class AppUpdateJob : IJob
{
private readonly UpdateProvider _updateProvider;
public AppUpdateJob(UpdateProvider updateProvider)
{
_updateProvider = updateProvider;
}
public string Name
{
get { return "Update Application Job"; }
}
public int DefaultInterval
{
get { return 0; }
}
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
notification.CurrentMessage = "Updating NzbDrone";
var updatePackage = _updateProvider.GetAvilableUpdate();
_updateProvider.StartUpdate(updatePackage);
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@ -12,12 +13,15 @@ using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{
class UpdateProvider
public class UpdateProvider
{
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private readonly ConfigFileProvider _configFileProvider;
private readonly EnviromentProvider _enviromentProvider;
private readonly ArchiveProvider _archiveProvider;
private readonly ProcessProvider _processProvider;
private readonly DiskProvider _diskProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly Regex parseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
@ -25,13 +29,16 @@ namespace NzbDrone.Core.Providers
[Inject]
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider)
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, ConfigFileProvider configFileProvider,
EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider, ProcessProvider processProvider, DiskProvider diskProvider)
{
_httpProvider = httpProvider;
_configProvider = configProvider;
_configFileProvider = configFileProvider;
_enviromentProvider = enviromentProvider;
_archiveProvider = archiveProvider;
_processProvider = processProvider;
_diskProvider = diskProvider;
}
public UpdateProvider()
@ -71,10 +78,16 @@ namespace NzbDrone.Core.Providers
return null;
}
public virtual void StartUpgrade(UpdatePackage updatePackage)
public virtual void StartUpdate(UpdatePackage updatePackage)
{
var packageDestination = Path.Combine(_enviromentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
if (_diskProvider.FolderExists(_enviromentProvider.GetUpdateSandboxFolder()))
{
logger.Info("Deleting old update files");
_diskProvider.DeleteFolder(_enviromentProvider.GetUpdateSandboxFolder(), true);
}
logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
_httpProvider.DownloadFile(updatePackage.Url, packageDestination);
logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
@ -82,6 +95,20 @@ namespace NzbDrone.Core.Providers
logger.Info("Extracting Update package");
_archiveProvider.ExtractArchive(packageDestination, _enviromentProvider.GetUpdateSandboxFolder());
logger.Info("Update package extracted successfully");
logger.Info("Preparing client");
_diskProvider.CopyDirectory(_enviromentProvider.GetUpdateClientFolder(), _enviromentProvider.GetUpdateSandboxFolder());
logger.Info("Starting update client");
var startInfo = new ProcessStartInfo()
{
FileName = _enviromentProvider.GetUpdateClientExePath(),
Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
};
_processProvider.Start(startInfo);
}
}

@ -30,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Practices.ServiceLocation">

@ -3,8 +3,10 @@ using System.Diagnostics;
namespace NzbDrone.Test.Dummy
{
class Program
public class DummyApp
{
public const string DUMMY_PROCCESS_NAME = "NzbDrone.Test.Dummy";
static void Main(string[] args)
{
Console.WriteLine("Dummy process. ID:{0} Path:{1}", Process.GetCurrentProcess().Id, Process.GetCurrentProcess().MainModule.FileName);

@ -43,7 +43,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="DummyApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

@ -48,7 +48,9 @@
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>

@ -64,7 +64,7 @@ namespace NzbDrone.Update.Test
_program.Start(new[] { "12", "" });
//Assert
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(ProcessPath), Times.Once());
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once());
}

@ -11,7 +11,8 @@
<RootNamespace>NzbDrone.Update</RootNamespace>
<AssemblyName>NzbDrone.Update</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@ -49,6 +50,7 @@
<Compile Include="Providers\UpdateProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Common;
@ -52,7 +53,8 @@ namespace NzbDrone.Update
VerfityArguments(args);
int processId = ParseProcessId(args);
string appPath = _processProvider.GetProcessById(processId).StartPath;
FileInfo exeFileInfo = new FileInfo(_processProvider.GetProcessById(processId).StartPath);
string appPath = exeFileInfo.Directory.FullName;
logger.Info("Starting update process");
_updateProvider.Start(appPath);

@ -12,5 +12,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
[assembly: AssemblyVersion("0.0.0.*")]
[assembly: AssemblyFileVersion("0.0.0.*")]

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

@ -56,12 +56,13 @@ namespace NzbDrone.Web
protected override IKernel CreateKernel()
{
LogManager.Configuration = new XmlLoggingConfiguration(new EnviromentProvider().GetNlogConfigPath(), false);
Common.LogConfiguration.RegisterUdpLogger();
Common.LogConfiguration.RegisterExceptioneer();
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
LogManager.Configuration = new XmlLoggingConfiguration(new EnviromentProvider().GetNlogConfigPath(), false);
var dispatch = new CentralDispatch();
Logger.Info("NzbDrone Starting up.");

@ -9,5 +9,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
[assembly: AssemblyVersion("0.0.0.*")]
[assembly: AssemblyFileVersion("0.0.0.*")]

@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
[assembly: AssemblyVersion("0.0.0.*")]
[assembly: AssemblyFileVersion("0.0.0.*")]

@ -53,9 +53,9 @@ namespace NzbDrone.Providers
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
//Set Variables for the config file.
startInfo.EnvironmentVariables.Add("NZBDRONE_PATH", _enviromentProvider.ApplicationPath);
startInfo.EnvironmentVariables.Add("NZBDRONE_PID", Process.GetCurrentProcess().Id.ToString());
startInfo.EnvironmentVariables[EnviromentProvider.NZBDRONE_PATH] = _enviromentProvider.ApplicationPath;
startInfo.EnvironmentVariables[EnviromentProvider.NZBDRONE_PID] = Process.GetCurrentProcess().Id.ToString();
try
{

@ -117,7 +117,7 @@ namespace NzbDrone.Providers
}.Submit();
}
Logger.FatalException("EPIC FAIL: {0}", excepion);
Logger.FatalException("EPIC FAIL: " + excepion.Message, excepion);
}
}
}

@ -4,10 +4,12 @@ SET TARGET=%PACKAGEROOT%\NzbDrone
rd %TARGET% /S /Q
del nzbdrone*.zip /Q /F
xcopy IISExpress %TARGET%\IISExpress /E /V /I /Y
xcopy NzbDrone\bin\Release\*.* %TARGET%\ /E /V /I /Y
xcopy NzbDrone.Update\bin\Release\*.* %TARGET%\NzbDrone.Update\ /E /V /I /Y
xcopy NzbDrone.Web\bin\*.* %TARGET%\NzbDrone.Web\bin\ /E /V /I /Y
xcopy NzbDrone.Web\App_GlobalResources\*.* %TARGET%\NzbDrone.Web\App_GlobalResources\ /E /V /I /Y
@ -15,7 +17,8 @@ xcopy NzbDrone.Web\Content\*.* %TARGET%\NzbDrone.Web\Content\ /E /V /I /Y
xcopy NzbDrone.Web\Scripts\*.* %TARGET%\NzbDrone.Web\Scripts\ /E /V /I /Y
xcopy NzbDrone.Web\Views\*.* %TARGET%\NzbDrone.Web\Views\ /E /V /I /Y
del %TARGET%\NzbDrone.Web\bin\*.xml /q
del %TARGET%\NzbDrone.Web\bin\*.xml /Q /F
xcopy NzbDrone.Web\log.config %TARGET%\NzbDrone.Web\
@ -27,6 +30,8 @@ xcopy NzbDrone.Web\web.config %TARGET%\NzbDrone.Web\
CD %PACKAGEROOT%
del nlog.xml /Q /F /S
del nlog.pdb /Q /F /S
del Twitterizer2.pdb /Q /F /S
del *.vshost.exe.* /Q /F /S
del ninject*.pdb /Q /F /S
del ninject*.xml /Q /F /S

Loading…
Cancel
Save