if (version < GetMinVersion())
{
CLog::Log(LOGNOTICE, "Attempting to update the database %s from version %i to %i", dbName.c_str(), version, GetMinVersion());
- if (UpdateOldVersion(version) && UpdateVersionNumber())
- CLog::Log(LOGINFO, "Update to version %i successfull", GetMinVersion());
- else
+ bool success = false;
+ BeginTransaction();
+ try
+ {
+ success = UpdateOldVersion(version);
+ if (success)
+ success = UpdateVersionNumber();
+ }
+ catch (...)
{
- CLog::Log(LOGERROR, "Can't update the database %s from version %i to %i", dbName.c_str(), version, GetMinVersion());
+ CLog::Log(LOGERROR, "Exception updating database %s from version %i to %i", dbName.c_str(), version, GetMinVersion());
+ success = false;
+ }
+ if (!success)
+ {
+ CLog::Log(LOGERROR, "Error updating database %s from version %i to %i", dbName.c_str(), version, GetMinVersion());
+ RollbackTransaction();
return false;
}
+ CommitTransaction();
+ CLog::Log(LOGINFO, "Update to version %i successful", GetMinVersion());
}
else if (version > GetMinVersion())
{