|
|
@ -20,12 +20,12 @@ using NzbDrone.Core.Update.Commands;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Update
|
|
|
|
namespace NzbDrone.Core.Update
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class InstallUpdateService : IExecute<ApplicationUpdateCommand>, IHandle<ApplicationStartingEvent>
|
|
|
|
public class InstallUpdateService : IExecute<ApplicationUpdateCommand>, IExecute<ApplicationUpdateCheckCommand>, IHandle<ApplicationStartingEvent>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ICheckUpdateService _checkUpdateService;
|
|
|
|
private readonly ICheckUpdateService _checkUpdateService;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
|
|
|
|
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
|
|
|
private readonly IDiskProvider _diskProvider;
|
|
|
|
private readonly IDiskProvider _diskProvider;
|
|
|
|
private readonly IDiskTransferService _diskTransferService;
|
|
|
|
private readonly IDiskTransferService _diskTransferService;
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
@ -41,6 +41,7 @@ namespace NzbDrone.Core.Update
|
|
|
|
|
|
|
|
|
|
|
|
public InstallUpdateService(ICheckUpdateService checkUpdateService,
|
|
|
|
public InstallUpdateService(ICheckUpdateService checkUpdateService,
|
|
|
|
IAppFolderInfo appFolderInfo,
|
|
|
|
IAppFolderInfo appFolderInfo,
|
|
|
|
|
|
|
|
IManageCommandQueue commandQueueManager,
|
|
|
|
IDiskProvider diskProvider,
|
|
|
|
IDiskProvider diskProvider,
|
|
|
|
IDiskTransferService diskTransferService,
|
|
|
|
IDiskTransferService diskTransferService,
|
|
|
|
IHttpClient httpClient,
|
|
|
|
IHttpClient httpClient,
|
|
|
@ -60,6 +61,7 @@ namespace NzbDrone.Core.Update
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_checkUpdateService = checkUpdateService;
|
|
|
|
_checkUpdateService = checkUpdateService;
|
|
|
|
_appFolderInfo = appFolderInfo;
|
|
|
|
_appFolderInfo = appFolderInfo;
|
|
|
|
|
|
|
|
_commandQueueManager = commandQueueManager;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_diskTransferService = diskTransferService;
|
|
|
|
_diskTransferService = diskTransferService;
|
|
|
|
_httpClient = httpClient;
|
|
|
|
_httpClient = httpClient;
|
|
|
@ -206,7 +208,7 @@ namespace NzbDrone.Core.Update
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(ApplicationUpdateCommand message)
|
|
|
|
private UpdatePackage GetUpdatePackage(CommandTrigger updateTrigger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.ProgressDebug("Checking for updates");
|
|
|
|
_logger.ProgressDebug("Checking for updates");
|
|
|
|
|
|
|
|
|
|
|
@ -215,13 +217,13 @@ namespace NzbDrone.Core.Update
|
|
|
|
if (latestAvailable == null)
|
|
|
|
if (latestAvailable == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.ProgressDebug("No update available");
|
|
|
|
_logger.ProgressDebug("No update available");
|
|
|
|
return;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically && message.Trigger != CommandTrigger.Manual)
|
|
|
|
if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically && updateTrigger != CommandTrigger.Manual)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.ProgressDebug("Auto-update not enabled, not installing available update");
|
|
|
|
_logger.ProgressDebug("Auto-update not enabled, not installing available update");
|
|
|
|
return;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -229,33 +231,51 @@ namespace NzbDrone.Core.Update
|
|
|
|
if (_configFileProvider.UpdateMechanism == UpdateMechanism.BuiltIn && _deploymentInfoProvider.IsExternalUpdateMechanism)
|
|
|
|
if (_configFileProvider.UpdateMechanism == UpdateMechanism.BuiltIn && _deploymentInfoProvider.IsExternalUpdateMechanism)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.ProgressDebug("Built-In updater disabled, please use {0} to install", _deploymentInfoProvider.PackageUpdateMechanism);
|
|
|
|
_logger.ProgressDebug("Built-In updater disabled, please use {0} to install", _deploymentInfoProvider.PackageUpdateMechanism);
|
|
|
|
return;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_configFileProvider.UpdateMechanism != UpdateMechanism.Script && _deploymentInfoProvider.IsExternalUpdateMechanism)
|
|
|
|
else if (_configFileProvider.UpdateMechanism != UpdateMechanism.Script && _deploymentInfoProvider.IsExternalUpdateMechanism)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.ProgressDebug("Update available, please use {0} to install", _deploymentInfoProvider.PackageUpdateMechanism);
|
|
|
|
_logger.ProgressDebug("Update available, please use {0} to install", _deploymentInfoProvider.PackageUpdateMechanism);
|
|
|
|
return;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
return latestAvailable;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
InstallUpdate(latestAvailable);
|
|
|
|
|
|
|
|
_logger.ProgressDebug("Restarting Sonarr to apply updates");
|
|
|
|
public void Execute(ApplicationUpdateCheckCommand message)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
catch (UpdateFolderNotWritableException ex)
|
|
|
|
if (GetUpdatePackage(message.Trigger) != null)
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.Error(ex, "Update process failed");
|
|
|
|
|
|
|
|
throw new CommandFailedException("Startup folder not writable by user '{0}'", ex, Environment.UserName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (UpdateVerificationFailedException ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Error(ex, "Update process failed");
|
|
|
|
_commandQueueManager.Push(new ApplicationUpdateCommand(), trigger: message.Trigger);
|
|
|
|
throw new CommandFailedException("Downloaded update package is corrupt", ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (UpdateFailedException ex)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(ApplicationUpdateCommand message)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var latestAvailable = GetUpdatePackage(message.Trigger);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (latestAvailable != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Error(ex, "Update process failed");
|
|
|
|
try
|
|
|
|
throw new CommandFailedException(ex);
|
|
|
|
{
|
|
|
|
|
|
|
|
InstallUpdate(latestAvailable);
|
|
|
|
|
|
|
|
_logger.ProgressDebug("Restarting Sonarr to apply updates");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (UpdateFolderNotWritableException ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.Error(ex, "Update process failed");
|
|
|
|
|
|
|
|
throw new CommandFailedException("Startup folder not writable by user '{0}'", ex, Environment.UserName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (UpdateVerificationFailedException ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.Error(ex, "Update process failed");
|
|
|
|
|
|
|
|
throw new CommandFailedException("Downloaded update package is corrupt", ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (UpdateFailedException ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.Error(ex, "Update process failed");
|
|
|
|
|
|
|
|
throw new CommandFailedException(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|