diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp @@ -442,6 +442,7 @@ GlobalDBSingleton::instance.scheduleOrRunCancellable( [=, &persistencePromise]() { try { + DatabaseManager::getQueryExecutor().beginTransaction(); if (persistContentModule) { DatabaseManager::getQueryExecutor().storeOlmPersistData( DatabaseManager::getQueryExecutor().getContentAccountID(), @@ -452,8 +453,10 @@ DatabaseManager::getQueryExecutor().getNotifsAccountID(), newNotifsPersist); } + DatabaseManager::getQueryExecutor().commitTransaction(); persistencePromise.set_value(); } catch (std::system_error &e) { + DatabaseManager::getQueryExecutor().rollbackTransaction(); persistencePromise.set_exception(std::make_exception_ptr(e)); } }); diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js --- a/web/shared-worker/worker/worker-crypto.js +++ b/web/shared-worker/worker/worker-crypto.js @@ -119,6 +119,7 @@ }; try { + sqliteQueryExecutor.beginTransaction(); sqliteQueryExecutor.storeOlmPersistAccount( sqliteQueryExecutor.getContentAccountID(), JSON.stringify(pickledContentAccount), @@ -130,7 +131,9 @@ sqliteQueryExecutor.getNotifsAccountID(), JSON.stringify(pickledNotificationAccount), ); + sqliteQueryExecutor.commitTransaction(); } catch (err) { + sqliteQueryExecutor.rollbackTransaction(); throw new Error(getProcessingStoreOpsExceptionMessage(err, dbModule)); } }