[mythtv] [patch] mythfilldatabase incorrectly reporting "potential
xmltv failure"
Dave Alden
alden at math.ohio-state.edu
Sun Dec 21 15:24:13 EST 2003
Hi,
mythfilldatabase improperly reports "mythfilldatabase ran, but did not insert any new
data into the Guide. This can indiciate a potential xmltv failure". The current logic
has it run "select max(endtime) from program" before and after each xmltv run. There
are 2 runs per xmltv source file (for 1 day out and <max-days> out). This works fine if
you only have one xmltv file, but if you have 2 or more, then the final run will (most
likely) have the same max(endtime) before and after - thereby generating the (again, most
likely) incorrect warning. To fix it I had it run the query at the beginning and end of
mythfilldatabase. I've enclosed a patch. :-)
...dave
-------------- next part --------------
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfilldatabase/filldata.cpp,v
retrieving revision 1.74
diff -u -r1.74 filldata.cpp
--- programs/mythfilldatabase/filldata.cpp 14 Dec 2003 23:56:41 -0000 1.74
+++ programs/mythfilldatabase/filldata.cpp 21 Dec 2003 20:13:09 -0000
@@ -1397,55 +1397,32 @@
QDateTime qdtNow = QDateTime::currentDateTime();
QSqlQuery query;
- QDateTime GuideDataThroughBefore, GuideDataThroughAfter;
QString status = "currently running.";
query.exec(QString("UPDATE settings SET data ='%1' "
"WHERE value='mythfilldatabaseLastRunStart'")
.arg(qdtNow.toString("yyyy-MM-dd hh:mm")));
- query.exec(QString("SELECT MAX(endtime) FROM program;"));
- if (query.isActive() && query.numRowsAffected())
- {
- query.next();
- GuideDataThroughBefore = QDateTime::fromString(query.value(0).toString(),
- Qt::ISODate);
- }
-
query.exec(QString("UPDATE settings SET data ='%1' "
"WHERE value='mythfilldatabaseLastRunStatus'")
.arg(status));
int systemcall_status = system(command.ascii());
- query.exec(QString("SELECT MAX(endtime) FROM program;"));
- if (query.isActive() && query.numRowsAffected())
- {
- query.next();
- GuideDataThroughAfter = QDateTime::fromString(query.value(0).toString(),
- Qt::ISODate);
- }
-
qdtNow = QDateTime::currentDateTime();
query.exec(QString("UPDATE settings SET data ='%1' "
"WHERE value='mythfilldatabaseLastRunEnd'")
.arg(qdtNow.toString("yyyy-MM-dd hh:mm")));
- status = "Successful.";
-
- if (systemcall_status == 0)
+ if (systemcall_status != 0)
{
- if (GuideDataThroughAfter == GuideDataThroughBefore)
- status = "mythfilldatabase ran, but did not insert "
- "any new data into the Guide. This can indicate a "
- "potential xmltv failure.";
- }
- else status = QString("FAILED: xmltv returned error code %1.")
- .arg(systemcall_status);
+ status = QString("FAILED: xmltv returned error code %1.")
+ .arg(systemcall_status);
- query.exec(QString("UPDATE settings SET data ='%1' "
- "WHERE value='mythfilldatabaseLastRunStatus'")
- .arg(status));
+ query.exec(QString("UPDATE settings SET data ='%1' "
+ "WHERE value='mythfilldatabaseLastRunStatus'")
+ .arg(status));
+ }
if (!quiet)
cout << "------------------ End of XMLTV output ------------------" << endl;
@@ -1491,6 +1468,18 @@
{
QValueList<Source>::Iterator it;
+ QString status;
+ QSqlQuery query;
+ QDateTime GuideDataThroughBefore, GuideDataThroughAfter;
+
+ query.exec(QString("SELECT MAX(endtime) FROM program;"));
+ if (query.isActive() && query.numRowsAffected())
+ {
+ query.next();
+ GuideDataThroughBefore = QDateTime::fromString(query.value(0).toString(),
+ Qt::ISODate);
+ }
+
int failures = 0;
for (it = sourcelist.begin(); it != sourcelist.end(); ++it) {
QString xmltv_grabber = (*it).xmltvgrabber;
@@ -1660,6 +1649,28 @@
}
}
+ query.exec(QString("SELECT MAX(endtime) FROM program;"));
+ if (query.isActive() && query.numRowsAffected())
+ {
+ query.next();
+ GuideDataThroughAfter = QDateTime::fromString(query.value(0).toString(),
+ Qt::ISODate);
+ }
+
+ if (failures == 0)
+ {
+ if (GuideDataThroughAfter == GuideDataThroughBefore)
+ status = "mythfilldatabase ran, but did not insert "
+ "any new data into the Guide. This can indicate a "
+ "potential xmltv failure.";
+ else
+ status = "Successful.";
+
+ query.exec(QString("UPDATE settings SET data ='%1' "
+ "WHERE value='mythfilldatabaseLastRunStatus'")
+ .arg(status));
+ }
+
clearOldDBEntries();
return (failures == 0);
More information about the mythtv-dev
mailing list