Skip to content

Commit

Permalink
pvr: stick the table creation in a transaction, and don't try to cont…
Browse files Browse the repository at this point in the history
…inue when the tables couldn't be created
  • Loading branch information
opdenkamp committed Apr 1, 2012
1 parent 94ece28 commit b3e96b3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions xbmc/pvr/PVRDatabase.cpp
Expand Up @@ -48,6 +48,7 @@ bool CPVRDatabase::CreateTables()
if (!CDatabase::CreateTables())
return false;

BeginTransaction();
CLog::Log(LOGINFO, "PVR - %s - creating tables", __FUNCTION__);

CLog::Log(LOGDEBUG, "PVR - %s - creating table 'clients'", __FUNCTION__);
Expand Down Expand Up @@ -153,25 +154,30 @@ bool CPVRDatabase::CreateTables()
")"
);

CommitTransaction();
bReturn = true;
}
catch (...)
{
CLog::Log(LOGERROR, "PVR - %s - unable to create PVR database tables (error %i)", __FUNCTION__, (int)GetLastError());
RollbackTransaction();
bReturn = false;
}

// disable all PVR add-on when started the first time
ADDON::VECADDONS addons;
if ((bReturn = CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true, false)) == false)
CLog::Log(LOGERROR, "PVR - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
if (bReturn)
{
CAddonDatabase database;
database.Open();
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
database.DisableAddon(it->get()->ID());
database.Close();
// disable all PVR add-on when started the first time
ADDON::VECADDONS addons;
if ((bReturn = CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true, false)) == false)
CLog::Log(LOGERROR, "PVR - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
{
CAddonDatabase database;
database.Open();
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
database.DisableAddon(it->get()->ID());
database.Close();
}
}

return bReturn;
Expand Down

0 comments on commit b3e96b3

Please sign in to comment.