Ticket #2194: housekeeper.diff

File housekeeper.diff, 1.4 KB (added by willu.mailingLists@…, 19 years ago)

An polished version of the patch with suggestions from the mailing list incorporated

  • programs/mythbackend/housekeeper.cpp

     
    5050    unsigned int longEnough = 0;
    5151
    5252    if (period)
    53         longEnough = ((period * oneday) - 600);
     53        longEnough = ((period * oneday) - oneday/2);
    5454    else
    5555        longEnough = oneday / 8;
    5656
     
    6969            result.next();
    7070            lastrun = result.value(0).toDateTime();
    7171
    72             if ((now.toTime_t() - lastrun.toTime_t()) > longEnough)
     72            if ((now.toTime_t() - lastrun.toTime_t()) > longEnough &&
     73                (now.toString(QString("d")).toInt() != lastrun.toString(QString("d")).toInt()))
    7374            {
    7475                int hour = now.toString(QString("h")).toInt();
    7576                if ((hour >= minhour) && (hour <= maxhour))
    76                     runOK = true;
     77                {
     78                    int minute = now.toString(QString("m")).toInt();
     79                    if ((hour == maxhour && minute > 30)
     80                            || ((random()%((maxhour-hour)*12+(60-minute)/5 - 6) == 0)))
     81                        runOK = true;
     82                }
    7783            }
    7884        }
    7985        else
     
    239245            updateLastrun(dbTag);
    240246        }
    241247
    242         sleep(300);
     248        sleep(300 + (random()%8));
    243249    }
    244250}
    245251