From 24d51093d6b993eb3edf8b80456967ebc2d9424b Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 16 Jan 2012 10:10:18 -0800 Subject: [PATCH] Fixed issue where AppUpdateJob would throw when there are no updates available. --- NzbDrone.Core.Test/JobTests/AppUpdateJobFixture.cs | 12 ++++++++++++ NzbDrone.Core/Jobs/AppUpdateJob.cs | 13 +++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/JobTests/AppUpdateJobFixture.cs b/NzbDrone.Core.Test/JobTests/AppUpdateJobFixture.cs index a61c84f73..1f15f2598 100644 --- a/NzbDrone.Core.Test/JobTests/AppUpdateJobFixture.cs +++ b/NzbDrone.Core.Test/JobTests/AppUpdateJobFixture.cs @@ -11,6 +11,7 @@ using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.JobTests { @@ -61,6 +62,7 @@ namespace NzbDrone.Core.Test.JobTests Mocker.GetMock().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never()); } + [Test] public void Should_download_update_package() { @@ -120,6 +122,16 @@ namespace NzbDrone.Core.Test.JobTests )); } + [Test] + public void when_no_updates_are_available_should_return_without_error_or_warnings() + { + Mocker.GetMock().Setup(c => c.GetAvilableUpdate()).Returns((UpdatePackage)null); + + StartUpdate(); + + ExceptionVerification.AssertNoUnexcpectedLogs(); + } + [Test] [Category(INTEGRATION_TEST)] public void Should_download_and_extract_to_temp_folder() diff --git a/NzbDrone.Core/Jobs/AppUpdateJob.cs b/NzbDrone.Core/Jobs/AppUpdateJob.cs index 55b270a6c..b5855c8bc 100644 --- a/NzbDrone.Core/Jobs/AppUpdateJob.cs +++ b/NzbDrone.Core/Jobs/AppUpdateJob.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Diagnostics; using System.IO; using NLog; +using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -22,7 +23,7 @@ namespace NzbDrone.Core.Jobs private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - + [Inject] public AppUpdateJob(UpdateProvider updateProvider, EnviromentProvider enviromentProvider, DiskProvider diskProvider, HttpProvider httpProvider, ProcessProvider processProvider, ArchiveProvider archiveProvider, ConfigFileProvider configFileProvider) { @@ -51,6 +52,10 @@ namespace NzbDrone.Core.Jobs var updatePackage = _updateProvider.GetAvilableUpdate(); + //No updates available + if (updatePackage == null) + return; + var packageDestination = Path.Combine(_enviromentProvider.GetUpdateSandboxFolder(), updatePackage.FileName); if (_diskProvider.FolderExists(_enviromentProvider.GetUpdateSandboxFolder())) @@ -75,13 +80,13 @@ namespace NzbDrone.Core.Jobs logger.Info("Starting update client"); - var startInfo = new ProcessStartInfo() - { + var startInfo = new ProcessStartInfo + { FileName = _enviromentProvider.GetUpdateClientExePath(), Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid) }; - var updateProcess = _processProvider.Start(startInfo); + _processProvider.Start(startInfo); notification.CurrentMessage = "Update in progress. NzbDrone will restart shortly."; } }