From fbf7d20c5d09b0fb528cfda18c7102b282df1091 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 13 Nov 2011 19:09:34 -0800 Subject: [PATCH] Fixed update client path issue --- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 2 +- ...mUpdateFixture.cs => StartUpdateFixture.cs} | 18 +++++++++--------- NzbDrone.Core/Providers/Jobs/AppUpdateJob.cs | 2 +- NzbDrone.Core/Providers/UpdateProvider.cs | 4 ++-- NzbDrone.Update.Test/ProgramFixture.cs | 2 +- NzbDrone.Update/Program.cs | 4 +++- 6 files changed, 17 insertions(+), 15 deletions(-) rename NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/{PreformUpdateFixture.cs => StartUpdateFixture.cs} (87%) diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 8df497f7e..5210dc9d5 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -92,7 +92,7 @@ - + diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/StartUpdateFixture.cs similarity index 87% rename from NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs rename to NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/StartUpdateFixture.cs index d2a9d7932..13e3b7d33 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/StartUpdateFixture.cs @@ -14,7 +14,7 @@ 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\"; @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests Mocker.GetMock().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(true); //Act - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); //Assert Mocker.GetMock().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true)); @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests Mocker.GetMock().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(false); //Act - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); //Assert Mocker.GetMock().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never()); @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName); //Act - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); //Assert Mocker.GetMock().Verify( @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName); //Act - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); //Assert Mocker.GetMock().Verify( @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests var updateClientFolder = Mocker.GetMock().Object.GetUpdateClientFolder(); //Act - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); //Assert Mocker.GetMock().Verify( @@ -108,13 +108,13 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests .SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12); //Act - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); //Assert Mocker.GetMock().Verify( c => c.Start(It.Is(p => p.FileName == updateClientPath && - p.Arguments == "/12 /" + _clientGuid.ToString()) + p.Arguments == "12 " + _clientGuid.ToString()) )); } @@ -134,7 +134,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests Mocker.Resolve(); Mocker.Resolve(); Mocker.Resolve(); - Mocker.Resolve().StartUpgrade(updatePackage); + Mocker.Resolve().StartUpdate(updatePackage); updateSubFolder.Refresh(); //Assert diff --git a/NzbDrone.Core/Providers/Jobs/AppUpdateJob.cs b/NzbDrone.Core/Providers/Jobs/AppUpdateJob.cs index 58ff10345..f404f7bef 100644 --- a/NzbDrone.Core/Providers/Jobs/AppUpdateJob.cs +++ b/NzbDrone.Core/Providers/Jobs/AppUpdateJob.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Providers.Jobs var updatePackage = _updateProvider.GetAvilableUpdate(); - _updateProvider.StartUpgrade(updatePackage); + _updateProvider.StartUpdate(updatePackage); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/UpdateProvider.cs b/NzbDrone.Core/Providers/UpdateProvider.cs index 454600020..c675bd606 100644 --- a/NzbDrone.Core/Providers/UpdateProvider.cs +++ b/NzbDrone.Core/Providers/UpdateProvider.cs @@ -78,7 +78,7 @@ 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); @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Providers var startInfo = new ProcessStartInfo() { FileName = _enviromentProvider.GetUpdateClientExePath(), - Arguments = string.Format("/{0} /{1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid) + Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid) }; _processProvider.Start(startInfo); diff --git a/NzbDrone.Update.Test/ProgramFixture.cs b/NzbDrone.Update.Test/ProgramFixture.cs index d5421930c..fd715e0c7 100644 --- a/NzbDrone.Update.Test/ProgramFixture.cs +++ b/NzbDrone.Update.Test/ProgramFixture.cs @@ -64,7 +64,7 @@ namespace NzbDrone.Update.Test _program.Start(new[] { "12", "" }); //Assert - Mocker.GetMock().Verify(c => c.Start(ProcessPath), Times.Once()); + Mocker.GetMock().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once()); } diff --git a/NzbDrone.Update/Program.cs b/NzbDrone.Update/Program.cs index 6816547ec..ed3cf0f34 100644 --- a/NzbDrone.Update/Program.cs +++ b/NzbDrone.Update/Program.cs @@ -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);