mirror of https://github.com/Radarr/Radarr
Jobs added to queue have higher priority than scheduler jobs.
This commit is contained in:
parent
3aa0a8f9ee
commit
4fe1d7e6f7
|
@ -490,6 +490,22 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void scheduled_job_should_have_scheduler_as_source()
|
||||
{
|
||||
IList<IJob> BaseFakeJobs = new List<IJob> { slowJob, fakeJob};
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
jobProvider.Initialize();
|
||||
ResetLastExecution();
|
||||
jobProvider.QueueScheduled();
|
||||
|
||||
jobProvider.Queue.Should().OnlyContain(c => c.Source == JobQueueItem.JobSourceType.Scheduler);
|
||||
|
||||
WaitForQueue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -139,17 +139,18 @@ namespace NzbDrone.Core.Jobs
|
|||
).Select(c => _jobs.Where(t => t.GetType().ToString() == c.TypeName).Single().GetType()).ToList();
|
||||
|
||||
|
||||
pendingJobTypes.ForEach(jobType => QueueJob(jobType));
|
||||
pendingJobTypes.ForEach(jobType => QueueJob(jobType, source: JobQueueItem.JobSourceType.Scheduler));
|
||||
logger.Trace("{0} Scheduled tasks have been added to the queue", pendingJobTypes.Count);
|
||||
}
|
||||
|
||||
public virtual void QueueJob(Type jobType, int targetId = 0, int secondaryTargetId = 0)
|
||||
public virtual void QueueJob(Type jobType, int targetId = 0, int secondaryTargetId = 0, JobQueueItem.JobSourceType source = JobQueueItem.JobSourceType.User)
|
||||
{
|
||||
var queueItem = new JobQueueItem
|
||||
{
|
||||
JobType = jobType,
|
||||
TargetId = targetId,
|
||||
SecondaryTargetId = secondaryTargetId
|
||||
SecondaryTargetId = secondaryTargetId,
|
||||
Source = source
|
||||
};
|
||||
|
||||
logger.Debug("Attempting to queue {0}", queueItem);
|
||||
|
@ -211,7 +212,7 @@ namespace NzbDrone.Core.Jobs
|
|||
{
|
||||
if (Queue.Count != 0)
|
||||
{
|
||||
job = Queue.First();
|
||||
job = Queue.OrderByDescending(c=>c.Source).First();
|
||||
logger.Trace("Popping {0} from the queue.", job);
|
||||
Queue.Remove(job);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace NzbDrone.Core.Model
|
|||
public int TargetId { get; set; }
|
||||
public int SecondaryTargetId { get; set; }
|
||||
|
||||
public JobSourceType Source { get; set; }
|
||||
|
||||
public bool Equals(JobQueueItem other)
|
||||
{
|
||||
return (JobType == other.JobType && TargetId == other.TargetId
|
||||
|
@ -18,5 +20,11 @@ namespace NzbDrone.Core.Model
|
|||
{
|
||||
return string.Format("[{0}({1}, {2})]", JobType.Name, TargetId, SecondaryTargetId);
|
||||
}
|
||||
|
||||
public enum JobSourceType
|
||||
{
|
||||
User,
|
||||
Scheduler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Model.Sabnzbd
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Common;
|
||||
|
|
Loading…
Reference in New Issue