Skip to content

Commit

Permalink
Remove some old code that was used for an out-of-sequence database up…
Browse files Browse the repository at this point in the history
…date.

In the 0.20-fixes days, we needed a database update to convert Zap2It Labs programid format to Schedules Direct format.  This was done in both 0.20-fixes and trunk with an out-of-sequence database update using a setting to determine if the update had been applied, and the code was kept in place to allow interoperability regardless of provider.

Since we no longer need the interoperability, this change simply moves the update to an official "in-sequence" update in trunk (though it has probably already run on everyone's system, so won't do anything), and removes the support code to simplify the code a bit.


git-svn-id: http://svn.mythtv.org/svn/trunk@25417 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
sphery committed Jul 25, 2010
1 parent 36ad2b5 commit 257abc2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 76 deletions.
9 changes: 0 additions & 9 deletions mythtv/libs/libmyth/dbutil.cpp
Expand Up @@ -262,15 +262,6 @@ MythDBBackupStatus DBUtil::BackupDB(QString &filename)
return kDB_Backup_Failed;
}

QMap<QString,bool> DBUtil::GetTableMap(void)
{
QMap<QString,bool> found_table;
const QStringList list = GetTables();
for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
found_table[*it] = true;
return found_table;
}

/** \fn DBUtil::GetTables(void)
* \brief Retrieves a list of tables from the database.
*
Expand Down
2 changes: 0 additions & 2 deletions mythtv/libs/libmyth/dbutil.h
Expand Up @@ -2,7 +2,6 @@
#define DBUTIL_H_

#include <QStringList>
#include <QMap>

#include "mythexp.h"
#include "mythdbcon.h"
Expand Down Expand Up @@ -39,7 +38,6 @@ class MPUBLIC DBUtil

MythDBBackupStatus BackupDB(QString &filename);

static QMap<QString,bool> GetTableMap(void);
static bool IsNewDatabase(void);
static bool IsBackupInProgress(void);
static int CountClients(void);
Expand Down
48 changes: 0 additions & 48 deletions mythtv/libs/libmythtv/datadirect.cpp
Expand Up @@ -926,54 +926,6 @@ void DataDirectProcessor::DataDirectProgramUpdate(void)
//cerr << "Done...\n";
}

void DataDirectProcessor::FixProgramIDs(void)
{
VERBOSE(VB_GENERAL, "DataDirectProcessor::FixProgramIDs() -- begin");
QMap<QString,bool> found_table = DBUtil::GetTableMap();

MSqlQuery query(MSqlQuery::DDCon());
query.prepare(
"UPDATE recorded "
"SET programid=CONCAT(SUBSTRING(programid, 1, 2), "
" '00', SUBSTRING(programid, 3)) "
"WHERE length(programid) = 12");

if (found_table["recorded"] && !query.exec())
{
MythDB::DBError("Fixing program ids in recorded", query);
return;
}

query.prepare(
"UPDATE oldrecorded "
"SET programid=CONCAT(SUBSTRING(programid, 1, 2), "
" '00', SUBSTRING(programid, 3)) "
"WHERE length(programid) = 12");

if (found_table["oldrecorded"] && !query.exec())
{
MythDB::DBError("Fixing program ids in oldrecorded", query);
return;
}

query.prepare(
"UPDATE program "
"SET programid=CONCAT(SUBSTRING(programid, 1, 2), "
" '00', SUBSTRING(programid, 3)) "
"WHERE length(programid) = 12");

if (found_table["program"] && !query.exec())
{
MythDB::DBError("Fixing program ids in program", query);
return;
}

if (found_table["settings"])
gCoreContext->SaveSetting("MythFillFixProgramIDsHasRunOnce", "1");

VERBOSE(VB_GENERAL, "DataDirectProcessor::FixProgramIDs() -- end");
}

FILE *DataDirectProcessor::DDPost(
QString ddurl,
QString postFilename, QString inputFile,
Expand Down
3 changes: 0 additions & 3 deletions mythtv/libs/libmythtv/datadirect.h
Expand Up @@ -329,9 +329,6 @@ class MPUBLIC DataDirectProcessor
uint sourceid, bool filter_new_channels);
static void DataDirectProgramUpdate(void);

// static command, makes Labs and Schedules Direct ProgramIDs compatible.
static void FixProgramIDs(void);

QStringList GetFatalErrors(void) const { return fatalErrors; }

private:
Expand Down
33 changes: 28 additions & 5 deletions mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -4,7 +4,6 @@ using namespace std;
#include <QString>
#include <QSqlError>
#include "dbcheck.h"
#include "datadirect.h" // for DataDirectProcessor::FixProgramIDs
#include "videodisplayprofile.h" // for "1214"

#include "dbutil.h"
Expand All @@ -20,7 +19,7 @@ using namespace std;
mythtv/bindings/python/MythTV/static.py
*/
/// This is the DB schema version expected by the running MythTV instance.
const QString currentDatabaseVersion = "1260";
const QString currentDatabaseVersion = "1261";

static bool UpdateDBVersionNumber(const QString &newnumber);
static bool performActualUpdate(
Expand Down Expand Up @@ -456,9 +455,6 @@ bool UpgradeTVDatabaseSchema(const bool upgradeAllowed,
GetMythDB()->SetSuppressDBMessages(true);
gCoreContext->ActivateSettingsCache(false);

if (!gCoreContext->GetNumSetting("MythFillFixProgramIDsHasRunOnce", 0))
DataDirectProcessor::FixProgramIDs();

DBup = SchemaUpgradeWizard::Get("DBSchemaVer", "MythTV",
currentDatabaseVersion);

Expand Down Expand Up @@ -5426,6 +5422,33 @@ NULL

if (!UpdateDBVersionNumber("1260"))
return false;

dbver = "1260";
}

if (dbver == "1260")
{
if (gCoreContext->GetNumSetting("MythFillFixProgramIDsHasRunOnce", 0))
{
if (!UpdateDBVersionNumber("1261"))
return false;
dbver = "1261";
}
else
{

const char *updates[] = {
"UPDATE recorded SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
" SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
"UPDATE oldrecorded SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
" SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
"UPDATE program SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
" SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
NULL
};
if (!performActualUpdate(updates, "1261", dbver))
return false;
}
}

return true;
Expand Down
10 changes: 1 addition & 9 deletions mythtv/programs/mythfilldatabase/main.cpp
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char *argv[])
bool from_file = false;
bool mark_repeats = true;

bool usingDataDirect = false, usingDataDirectLabs = false;
bool usingDataDirect = false;
bool grab_data = true;

bool export_iconmap = false;
Expand Down Expand Up @@ -634,8 +634,6 @@ int main(int argc, char *argv[])
sourcelist.push_back(newsource);
usingDataDirect |=
is_grabber_datadirect(newsource.xmltvgrabber);
usingDataDirectLabs |=
is_grabber_labs(newsource.xmltvgrabber);
}
}
else
Expand Down Expand Up @@ -945,12 +943,6 @@ int main(int argc, char *argv[])
fill_data.ddprocessor.GrabNextSuggestedTime();
}

if (usingDataDirectLabs ||
!gCoreContext->GetNumSetting("MythFillFixProgramIDsHasRunOnce", 0))
{
DataDirectProcessor::FixProgramIDs();
}

VERBOSE(VB_GENERAL, "\n"
"===============================================================\n"
"| Attempting to contact the master backend for rescheduling. |\n"
Expand Down

0 comments on commit 257abc2

Please sign in to comment.