Fixed: Schedule refresh and process monitored download tasks at high priority
This commit is contained in:
parent
66be23a7c4
commit
7a0090c7a2
|
@ -158,6 +158,8 @@ namespace NzbDrone.Core.Jobs
|
||||||
currentDefinition.LastExecution = DateTime.UtcNow;
|
currentDefinition.LastExecution = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentDefinition.Priority = defaultTask.Priority;
|
||||||
|
|
||||||
_cache.Set(currentDefinition.TypeName, currentDefinition);
|
_cache.Set(currentDefinition.TypeName, currentDefinition);
|
||||||
_scheduledTaskRepository.Upsert(currentDefinition);
|
_scheduledTaskRepository.Upsert(currentDefinition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Messaging.Commands
|
||||||
|
{
|
||||||
|
public class CommandPriorityComparer: IComparer<CommandStatus>
|
||||||
|
{
|
||||||
|
public int Compare(CommandStatus x, CommandStatus y)
|
||||||
|
{
|
||||||
|
if (x == CommandStatus.Started && y != CommandStatus.Started)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x != CommandStatus.Started && y == CommandStatus.Started)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < y)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x > y)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,8 @@ namespace Sonarr.Api.V3.Commands
|
||||||
private readonly Debouncer _debouncer;
|
private readonly Debouncer _debouncer;
|
||||||
private readonly Dictionary<int, CommandResource> _pendingUpdates;
|
private readonly Dictionary<int, CommandResource> _pendingUpdates;
|
||||||
|
|
||||||
|
private readonly CommandPriorityComparer _commandPriorityComparer = new CommandPriorityComparer();
|
||||||
|
|
||||||
public CommandModule(IManageCommandQueue commandQueueManager,
|
public CommandModule(IManageCommandQueue commandQueueManager,
|
||||||
IBroadcastSignalRMessage signalRBroadcaster,
|
IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
IServiceFactory serviceFactory)
|
IServiceFactory serviceFactory)
|
||||||
|
@ -65,7 +67,10 @@ namespace Sonarr.Api.V3.Commands
|
||||||
|
|
||||||
private List<CommandResource> GetStartedCommands()
|
private List<CommandResource> GetStartedCommands()
|
||||||
{
|
{
|
||||||
return _commandQueueManager.All().ToResource();
|
return _commandQueueManager.All()
|
||||||
|
.OrderBy(c => c.Status, _commandPriorityComparer)
|
||||||
|
.ThenByDescending(c => c.Priority)
|
||||||
|
.ToResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CancelCommand(int id)
|
private void CancelCommand(int id)
|
||||||
|
|
Loading…
Reference in New Issue