Skip to content

Commit

Permalink
Fix the DB schema version check. Backports [24820] from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.mythtv.org/svn/branches/release-0-23-fixes@24821 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
sphery committed May 23, 2010
1 parent 4f87f00 commit 789f388
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 13 additions & 0 deletions mythtv/libs/libmyth/schemawizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ SchemaUpgradeWizard::PromptForUpgrade(const char *name,
return MYTH_SCHEMA_USE_EXISTING;
#endif

// Only back up the database if it's old/about to be upgraded
// (not if it's too new)
// or if a user is doing something they probably shouldn't ("expert mode")
if ((upgradeAllowed && (versionsBehind > 0)) || m_expertMode)
BackupDB();

connections = CountClients() > 1;
gui = GetMythUI()->IsScreenSetup() && gContext->GetMainWindow();
Expand Down Expand Up @@ -314,6 +319,14 @@ SchemaUpgradeWizard::PromptForUpgrade(const char *name,
return MYTH_SCHEMA_EXIT;
}

if (versionsBehind < 0)
{
VERBOSE(VB_IMPORTANT, QString("Error: MythTV database has newer "
"%1 schema (%2) than expected (%3).")
.arg(name).arg(DBver).arg(m_newSchemaVer));
return MYTH_SCHEMA_ERROR;
}

if (upgradeIfNoUI && validDBMS)
{
VERBOSE(VB_IMPORTANT, "Upgrading.");
Expand Down
9 changes: 2 additions & 7 deletions mythtv/libs/libmythtv/dbcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,8 @@ bool UpgradeTVDatabaseSchema(const bool upgradeAllowed,
return true;
}

// An upgrade is likely. We do the backup first so that
// the UI can tell the user where the backup is located.
if (upgradeAllowed)
DBup->BackupDB();
else
VERBOSE(VB_IMPORTANT, "Not allowed to upgrade the database. "
"Skipping backup.");
if (!upgradeAllowed)
VERBOSE(VB_IMPORTANT, "Not allowed to upgrade the database.");

// Pop up messages, questions, warnings, et c.
switch (DBup->PromptForUpgrade("TV", upgradeAllowed,
Expand Down

0 comments on commit 789f388

Please sign in to comment.