Ticket #3842: 3842-housekeeper-cleanup-v1.patch
| File 3842-housekeeper-cleanup-v1.patch, 3.5 KB (added by , 18 years ago) |
|---|
-
programs/mythbackend/housekeeper.cpp
62 62 QDateTime lastrun; 63 63 lastrun.setTime_t(0); 64 64 65 if (minhour < 0) 66 minhour = 0; 67 if (maxhour > 23) 68 maxhour = 23; 65 minhour = (minhour < 0) ? 0 : minhour; 66 maxhour = (maxhour > 23) ? 23 : maxhour; 69 67 70 MSqlQuery result(MSqlQuery::InitCon()); 71 if (result.isConnected()) 68 MSqlQuery query(MSqlQuery::InitCon()); 69 if (!query.isConnected()) 70 return runOK; 71 72 query.prepare("SELECT lastrun FROM housekeeping WHERE tag = :TAG ;"); 73 query.bindValue(":TAG", dbTag); 74 bool ok = query.exec(); 75 76 if (ok && query.next()) 72 77 { 73 result.prepare("SELECT lastrun FROM housekeeping WHERE tag = :TAG ;"); 74 result.bindValue(":TAG", dbTag); 78 lastrun = query.value(0).toDateTime(); 75 79 76 if (result.exec() && result.isActive() && result.size() > 0) 80 if ((lastrun.secsTo(now) > longEnough) && 81 (now.date().day() != lastrun.date().day())) 77 82 { 78 result.next(); 79 lastrun = result.value(0).toDateTime(); 83 int hour = now.time().hour(); 80 84 81 if ((lastrun.secsTo(now) > longEnough) && 82 (now.date().day() != lastrun.date().day())) 85 if (((minhour > maxhour) && 86 ((hour <= maxhour) || (hour >= minhour))) || 87 ((hour >= minhour) && (hour <= maxhour))) 83 88 { 84 int hour = now.time().hour(); 85 86 if (((minhour > maxhour) && 87 ((hour <= maxhour) || (hour >= minhour))) || 88 ((hour >= minhour) && (hour <= maxhour))) 89 int minute = now.time().minute(); 90 if ((hour == maxhour && minute > 30) || 91 ((random()%(((maxhour-hour)*12+ 92 (60-minute)/5 - 6) + 1)) == 0)) 89 93 { 90 int minute = now.time().minute();91 if ((hour == maxhour && minute > 30) ||92 ((random()%(((maxhour-hour)*12+(60-minute)/5 - 6) + 1)) == 0))93 94 runOK = true; 94 95 } 95 96 } 96 97 } 97 else 98 { 99 result.prepare("INSERT INTO housekeeping(tag,lastrun) " 100 "values(:TAG ,now());"); 101 result.bindValue(":TAG", dbTag); 102 result.exec(); 98 } 99 else 100 { 101 if (!ok) 102 MythContext::DBError("wantToRun failure", query); 103 103 104 runOK = true; 105 } 104 query.prepare("INSERT INTO housekeeping(tag,lastrun) " 105 "VALUES(:TAG ,now());"); 106 query.bindValue(":TAG", dbTag); 107 query.exec(); 108 109 runOK = true; 106 110 } 107 111 108 112 return runOK; … … 222 226 QDateTime lastRun = getLastRun("MythFillDB"); 223 227 QDateTime now = QDateTime::currentDateTime(); 224 228 225 if((nextRun < now) &&226 (lastRun.secsTo(now) > (3 * 60 * 60)))227 runMythFill = true;229 runMythFill |= ((nextRun < now) && 230 (lastRun.secsTo(now) > (3 * 60 * 60))); 231 228 232 } 229 233 else if (wantToRun("MythFillDB", period, minhr, maxhr)) 230 234 {
