File indexing completed on 2025-01-05 04:47:01
0001 /* 0002 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "transaction.h" 0008 #include "storage/datastore.h" 0009 0010 using namespace Akonadi::Server; 0011 0012 Transaction::Transaction(DataStore *db, const QString &name, bool beginTransaction) 0013 : mDb(db) 0014 , mName(name) 0015 , mCommitted(false) 0016 { 0017 if (beginTransaction) { 0018 mDb->beginTransaction(mName); 0019 } 0020 } 0021 0022 Transaction::~Transaction() 0023 { 0024 if (!mCommitted) { 0025 mDb->rollbackTransaction(); 0026 } 0027 } 0028 0029 bool Transaction::commit() 0030 { 0031 mCommitted = true; 0032 return mDb->commitTransaction(); 0033 } 0034 0035 void Transaction::begin() 0036 { 0037 mDb->beginTransaction(mName); 0038 mCommitted = false; 0039 }