mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
Fixed: Don't lock command queue if updating is disabled
This commit is contained in:
parent
3cccbdecb7
commit
1a2cd6af54
3 changed files with 58 additions and 27 deletions
|
@ -63,7 +63,7 @@ namespace NzbDrone.Core.Jobs
|
||||||
{
|
{
|
||||||
new ScheduledTask { Interval = 1, TypeName = typeof(CheckForFinishedDownloadCommand).FullName },
|
new ScheduledTask { Interval = 1, TypeName = typeof(CheckForFinishedDownloadCommand).FullName },
|
||||||
new ScheduledTask { Interval = 5, TypeName = typeof(MessagingCleanupCommand).FullName },
|
new ScheduledTask { Interval = 5, TypeName = typeof(MessagingCleanupCommand).FullName },
|
||||||
new ScheduledTask { Interval = 6 * 60, TypeName = typeof(ApplicationUpdateCommand).FullName },
|
new ScheduledTask { Interval = 6 * 60, TypeName = typeof(ApplicationUpdateCheckCommand).FullName },
|
||||||
new ScheduledTask { Interval = 6 * 60, TypeName = typeof(CheckHealthCommand).FullName },
|
new ScheduledTask { Interval = 6 * 60, TypeName = typeof(CheckHealthCommand).FullName },
|
||||||
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RefreshArtistCommand).FullName },
|
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RefreshArtistCommand).FullName },
|
||||||
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RescanFoldersCommand).FullName },
|
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RescanFoldersCommand).FullName },
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Update.Commands
|
||||||
|
{
|
||||||
|
public class ApplicationUpdateCheckCommand : Command
|
||||||
|
{
|
||||||
|
public override bool SendUpdatesToClient => true;
|
||||||
|
|
||||||
|
public override string CompletionMessage => null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,12 +16,12 @@ using NzbDrone.Core.Update.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Update
|
namespace NzbDrone.Core.Update
|
||||||
{
|
{
|
||||||
public class InstallUpdateService : IExecute<ApplicationUpdateCommand>
|
public class InstallUpdateService : IExecute<ApplicationUpdateCheckCommand>, IExecute<ApplicationUpdateCommand>
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -37,6 +37,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,
|
||||||
|
@ -58,6 +59,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;
|
||||||
|
@ -204,7 +206,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");
|
||||||
|
|
||||||
|
@ -213,52 +215,70 @@ 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.IsDocker)
|
if (_osInfo.IsDocker)
|
||||||
{
|
{
|
||||||
_logger.ProgressDebug("Updating is disabled inside a docker container. Please update the container image.");
|
_logger.ProgressDebug("Updating is disabled inside a docker container. Please update the container image.");
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety net, ConfigureUpdateMechanism should take care of invalid settings
|
// Safety net, ConfigureUpdateMechanism should take care of invalid settings
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(ApplicationUpdateCheckCommand message)
|
||||||
|
{
|
||||||
|
if (GetUpdatePackage(message.Trigger) != null)
|
||||||
{
|
{
|
||||||
InstallUpdate(latestAvailable);
|
_commandQueueManager.Push(new ApplicationUpdateCommand(), trigger: message.Trigger);
|
||||||
_logger.ProgressDebug("Restarting Lidarr to apply updates");
|
|
||||||
}
|
}
|
||||||
catch (UpdateFolderNotWritableException ex)
|
}
|
||||||
|
|
||||||
|
public void Execute(ApplicationUpdateCommand message)
|
||||||
|
{
|
||||||
|
var latestAvailable = GetUpdatePackage(message.Trigger);
|
||||||
|
|
||||||
|
if (latestAvailable != null)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "Update process failed");
|
try
|
||||||
throw new CommandFailedException("Startup folder not writable by user '{0}'", ex, Environment.UserName);
|
{
|
||||||
}
|
InstallUpdate(latestAvailable);
|
||||||
catch (UpdateVerificationFailedException ex)
|
_logger.ProgressDebug("Restarting Lidarr to apply updates");
|
||||||
{
|
}
|
||||||
_logger.Error(ex, "Update process failed");
|
catch (UpdateFolderNotWritableException ex)
|
||||||
throw new CommandFailedException("Downloaded update package is corrupt", ex);
|
{
|
||||||
}
|
_logger.Error(ex, "Update process failed");
|
||||||
catch (UpdateFailedException ex)
|
throw new CommandFailedException("Startup folder not writable by user '{0}'", ex, Environment.UserName);
|
||||||
{
|
}
|
||||||
_logger.Error(ex, "Update process failed");
|
catch (UpdateVerificationFailedException ex)
|
||||||
throw new CommandFailedException(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue