Browse files

factor out the Update() function in CDatabase::Open

  • Loading branch information...
1 parent f656311 commit fd165ea2ba4e0b0934e64fe79f4534396fc8997b Jonathan Marshall committed Jul 7, 2012
Showing with 14 additions and 0 deletions.
  1. +12 −0 xbmc/dbwrappers/Database.cpp
  2. +2 −0 xbmc/dbwrappers/Database.h
View
12 xbmc/dbwrappers/Database.cpp
@@ -279,6 +279,18 @@ bool CDatabase::Open(const DatabaseSettings &settings)
if (dbSettings.name.IsEmpty())
dbSettings.name = GetBaseDBName();
+ CStdString dbName = dbSettings.name;
+ dbName.AppendFormat("%d", GetMinVersion());
+ if (!Connect(dbName, dbSettings, false) || GetDBVersion() != GetMinVersion())
+ {
+ if (!Update(dbSettings))
+ return false;
+ }
+ return true;
+}
+
+bool CDatabase::Update(const DatabaseSettings &dbSettings)
+{
int version = GetMinVersion();
CStdString latestDb = dbSettings.name;
latestDb.AppendFormat("%d", version);
View
2 xbmc/dbwrappers/Database.h
@@ -114,6 +114,8 @@ class CDatabase
bool CommitInsertQueries();
protected:
+ bool Update(const DatabaseSettings &db);
+
void Split(const CStdString& strFileNameAndPath, CStdString& strPath, CStdString& strFileName);
uint32_t ComputeCRC(const CStdString &text);

0 comments on commit fd165ea

Please sign in to comment.