mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-24 06:50:43 +00:00
Don't block task queue for queued update task when long running tasks queued
Fixes #2935 Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
5a8082de2d
commit
93cce9a02e
5 changed files with 45 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.ImportLists;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Music.Commands;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -25,6 +26,18 @@ private void GivenStartedDiskCommand()
|
|||
Subject.Add(commandModel);
|
||||
}
|
||||
|
||||
private void GivenLongRunningCommand()
|
||||
{
|
||||
var commandModel = Builder<CommandModel>
|
||||
.CreateNew()
|
||||
.With(c => c.Name = "RssSync")
|
||||
.With(c => c.Body = new RssSyncCommand())
|
||||
.With(c => c.Status = CommandStatus.Started)
|
||||
.Build();
|
||||
|
||||
Subject.Add(commandModel);
|
||||
}
|
||||
|
||||
private void GivenStartedTypeExclusiveCommand()
|
||||
{
|
||||
var commandModel = Builder<CommandModel>
|
||||
|
@ -85,6 +98,24 @@ public void should_not_return_type_exclusive_command_if_another_running()
|
|||
command.Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_return_exclusive_command_if_long_running_command_running()
|
||||
{
|
||||
GivenLongRunningCommand();
|
||||
|
||||
var newCommandModel = Builder<CommandModel>
|
||||
.CreateNew()
|
||||
.With(c => c.Name = "ApplicationUpdate")
|
||||
.With(c => c.Body = new ApplicationUpdateCommand())
|
||||
.Build();
|
||||
|
||||
Subject.Add(newCommandModel);
|
||||
|
||||
Subject.TryGet(out var command);
|
||||
|
||||
command.Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_return_type_exclusive_command_if_another_and_disk_access_command_running()
|
||||
{
|
||||
|
|
|
@ -5,5 +5,7 @@ namespace NzbDrone.Core.Download
|
|||
public class ProcessMonitoredDownloadsCommand : Command
|
||||
{
|
||||
public override bool RequiresDiskAccess => true;
|
||||
|
||||
public override bool IsLongRunning => true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,7 @@ namespace NzbDrone.Core.Indexers
|
|||
public class RssSyncCommand : Command
|
||||
{
|
||||
public override bool SendUpdatesToClient => true;
|
||||
|
||||
public override bool IsLongRunning => true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ public virtual bool SendUpdatesToClient
|
|||
public virtual string CompletionMessage => "Completed";
|
||||
public virtual bool RequiresDiskAccess => false;
|
||||
public virtual bool IsExclusive => false;
|
||||
|
||||
public virtual bool IsTypeExclusive => false;
|
||||
public virtual bool IsLongRunning => false;
|
||||
|
||||
public string Name { get; private set; }
|
||||
public DateTime? LastExecutionTime { get; set; }
|
||||
|
|
|
@ -176,6 +176,11 @@ public bool TryGet(out CommandModel item)
|
|||
queuedCommands = queuedCommands.Where(c => !exclusiveTypes.Any(x => x == c.Body.Name));
|
||||
}
|
||||
|
||||
if (startedCommands.Any(x => x.Body.IsLongRunning))
|
||||
{
|
||||
queuedCommands = queuedCommands.Where(c => c.Status == CommandStatus.Queued && !c.Body.IsExclusive);
|
||||
}
|
||||
|
||||
var localItem = queuedCommands.OrderByDescending(c => c.Priority)
|
||||
.ThenBy(c => c.QueuedAt)
|
||||
.FirstOrDefault();
|
||||
|
|
Loading…
Reference in a new issue