diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2022-12-19 06:13:25 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-19 06:13:25 +1000 |
commit | 6bbec982d8c39b7835095ba348ff75065cea6739 (patch) | |
tree | c000d1b902f48e7450ad41fe6b708cf763dcabce | |
parent | c19adeae47e70143265395f7ddb56cfbffd14647 (diff) | |
parent | b85a32e95cd3b1accee64057de9080fde4935332 (diff) |
Merge pull request #22284 from thexai/fix-Xbox-database-Nexus
[Xbox][Database] Fix race condition at upgrade databases version
-rw-r--r-- | xbmc/DatabaseManager.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/xbmc/DatabaseManager.cpp b/xbmc/DatabaseManager.cpp index 5398ff3175..33f38e8766 100644 --- a/xbmc/DatabaseManager.cpp +++ b/xbmc/DatabaseManager.cpp @@ -166,10 +166,29 @@ bool CDatabaseManager::UpdateVersion(CDatabase &db, const std::string &dbName) version, db.GetSchemaVersion()); bool success = true; db.BeginTransaction(); + try { - // drop old analytics, update table(s), recreate analytics, update version + // drop old analytics db.DropAnalytics(); + } + catch (...) + { + success = false; + } + if (!success) + { + CLog::Log(LOGERROR, "Exception droping old analytics from {}", dbName); + db.RollbackTransaction(); + return false; + } + + db.CommitTransaction(); + db.BeginTransaction(); + + try + { + // update table(s), recreate analytics, update version db.UpdateTables(version); db.CreateAnalytics(); db.UpdateVersionNumber(); |