aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthexai <58434170+thexai@users.noreply.github.com>2022-12-18 08:06:01 +0100
committerthexai <58434170+thexai@users.noreply.github.com>2022-12-18 08:34:58 +0100
commitb85a32e95cd3b1accee64057de9080fde4935332 (patch)
treec000d1b902f48e7450ad41fe6b708cf763dcabce
parentc19adeae47e70143265395f7ddb56cfbffd14647 (diff)
[Xbox][Database] Fix race condition at upgrade databases version
-rw-r--r--xbmc/DatabaseManager.cpp21
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();