Ticket #5042: jobqueuepatch.patch

File jobqueuepatch.patch, 4.3 KB (added by Scott.Atkins@…, 12 years ago)

Jobqueue patch

  • (a) jobqueue.cpp vs. (b) Copy

    a b  
    573573    return true;
    574574}
    575575
     576// Order of jobs:
     577// if auto transcode is not deferred
     578//  if auto comm flag is to run before auto transcode
     579//   auto comm flag
     580//   auto transcode
     581//  else
     582//   auto transcode
     583//   auto comm flag
     584//  end if
     585//  else
     586//  if auto comm flag is to run before auto transcode
     587//   auto comm flag
     588//  end if
     589// end if
     590// user job 1
     591// user job 2
     592// user job 3
     593// user job 4
     594// if auto transcode is deferred
     595//  auto transcode @ date specified
     596//  if !auto comm flag before auto transcode
     597//   auto comm flag @ date specified
     598//  end if
     599// end if
    576600bool JobQueue::QueueJobs(int jobTypes, QString chanid, QDateTime starttime,
    577601                         QString args, QString comment, QString host)
    578602{
    579     if (gContext->GetNumSetting("AutoTranscodeBeforeAutoCommflag", 0))
    580     {
    581         if (jobTypes & JOB_TRANSCODE)
    582             QueueJob(JOB_TRANSCODE, chanid, starttime, args, comment, host);
    583         if (jobTypes & JOB_COMMFLAG)
    584             QueueJob(JOB_COMMFLAG, chanid, starttime, args, comment, host);
    585     }
    586     else
    587     {
    588         if (jobTypes & JOB_COMMFLAG)
    589             QueueJob(JOB_COMMFLAG, chanid, starttime, args, comment, host);
    590         if (jobTypes & JOB_TRANSCODE)
    591         {
    592             QDateTime schedruntime = QDateTime::currentDateTime();
     603    int defer = 0;
    593604
    594             int defer = gContext->GetNumSetting("DeferAutoTranscodeDays", 0);
    595             if (defer)
    596             {
    597                 schedruntime = schedruntime.addDays(defer);
    598                 schedruntime.setTime(QTime::QTime(0,0));
    599             }
     605    // We only care about deferring when the transcode job is enabled
     606    if(jobTypes & JOB_TRANSCODE)
     607        defer = gContext->GetNumSetting("DeferAutoTranscodeDays", 0);
    600608
    601             QueueJob(JOB_TRANSCODE, chanid, starttime, args, comment, host,
    602               0, JOB_QUEUED, schedruntime);
     609    int transBeforeComm = gContext->GetNumSetting("AutoTranscodeBeforeAutoCommflag", 0);
     610   
     611    // if the transcode job isn't being deferred, run as normal
     612    if(!defer)
     613    {
     614        if (transBeforeComm)
     615        {
     616            if (jobTypes & JOB_TRANSCODE)
     617                QueueJob(JOB_TRANSCODE, chanid, starttime, args, comment, host);
     618            if (jobTypes & JOB_COMMFLAG)
     619                QueueJob(JOB_COMMFLAG, chanid, starttime, args, comment, host);
     620        }
     621        else
     622        {
     623            if (jobTypes & JOB_COMMFLAG)
     624                QueueJob(JOB_COMMFLAG, chanid, starttime, args, comment, host);
     625            if (jobTypes & JOB_TRANSCODE)
     626                QueueJob(JOB_TRANSCODE, chanid, starttime, args, comment, host);
     627        }
     628    }else{
     629       
     630        // If we are deferring the transcode job, but auto comm flag is set
     631        // to run before transcoding, run it before the user jobs
     632        if(!transBeforeComm)
     633        {
     634            if (jobTypes & JOB_COMMFLAG)
     635                QueueJob(JOB_COMMFLAG, chanid, starttime, args, comment, host);
    603636        }
    604637    }
    605638
     
    611644        QueueJob(JOB_USERJOB3, chanid, starttime, args, comment, host);
    612645    if (jobTypes & JOB_USERJOB4)
    613646        QueueJob(JOB_USERJOB4, chanid, starttime, args, comment, host);
     647   
     648    if (defer)
     649    {
     650        QDateTime schedruntime = QDateTime::currentDateTime();
     651
     652        schedruntime = schedruntime.addDays(defer);
     653        // Removed as this would cause all programs to be transcoded at
     654        // the same time rather than staggering them in any way.  At
     655        // least this way, they'll be staggered based on when they were
     656        // recorded (and you'll be able to tell which job is which in
     657        // the job list).
     658        // schedruntime.setTime(QTime::QTime(0,0));
     659
     660        QueueJob(JOB_TRANSCODE, chanid, starttime, args, comment, host,
     661            0, JOB_QUEUED, schedruntime);
     662        if(transBeforeComm)
     663        {
     664            // Using the same QueueJob method as auto transcode to show the
     665            // time when it will run not just queued
     666            if(jobTypes & JOB_COMMFLAG)
     667                QueueJob(JOB_COMMFLAG, chanid, starttime, args, comment, host,
     668                    0, JOB_QUEUED, schedruntime);
     669        }
     670    }
    614671
    615672    return true;
    616673}