Skip to content
Browse files

factor out the initializing of database settings from CDatabase::Open

  • Loading branch information...
1 parent fd165ea commit adc13132222858f679173ef5b50e19ef40a4b0a7 Jonathan Marshall committed
Showing with 16 additions and 12 deletions.
  1. +15 −12 xbmc/dbwrappers/Database.cpp
  2. +1 −0 xbmc/dbwrappers/Database.h
View
27 xbmc/dbwrappers/Database.cpp
@@ -249,15 +249,27 @@ bool CDatabase::Open()
bool CDatabase::Open(const DatabaseSettings &settings)
{
- // take a copy - we're gonna be messing with it and we don't want to touch the original
- DatabaseSettings dbSettings = settings;
-
if (IsOpen())
{
m_openCount++;
return true;
}
+ DatabaseSettings dbSettings = settings;
+ InitSettings(dbSettings);
+
+ CStdString dbName = dbSettings.name;
+ dbName.AppendFormat("%d", GetMinVersion());
+ if (!Connect(dbName, dbSettings, false) || GetDBVersion() != GetMinVersion())
+ {
+ if (!Update(dbSettings))
+ return false;
+ }
+ return true;
+}
+
+void CDatabase::InitSettings(DatabaseSettings &dbSettings)
+{
m_sqlite = true;
if ( dbSettings.type.Equals("mysql") )
@@ -278,15 +290,6 @@ bool CDatabase::Open(const DatabaseSettings &settings)
// use separate, versioned database
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)
View
1 xbmc/dbwrappers/Database.h
@@ -137,6 +137,7 @@ class CDatabase
std::auto_ptr<dbiplus::Dataset> m_pDS2;
private:
+ void InitSettings(DatabaseSettings &dbSettings);
bool Connect(const CStdString &dbName, const DatabaseSettings &db, bool create);
bool UpdateVersionNumber();

0 comments on commit adc1313

Please sign in to comment.
Something went wrong with that request. Please try again.