Changeset View
Changeset View
Standalone View
Standalone View
src/engine/transaction.h
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * This file is part of the KDE Baloo project. | 2 | * This file is part of the KDE Baloo project. | ||
3 | * Copyright (C) 2015 Vishesh Handa <vhanda@kde.org> | 3 | * Copyright (C) 2015 Vishesh Handa <vhanda@kde.org> | ||
4 | * Copyright (C) 2018 Michael Heidelbach <ottwolt@gmail.com> | ||||
4 | * | 5 | * | ||
5 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
7 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
8 | * version 2.1 of the License, or (at your option) any later version. | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
9 | * | 10 | * | ||
10 | * This library is distributed in the hope that it will be useful, | 11 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 110 | void removeRecursively(quint64 id, Functor shouldDelete) { | |||
111 | Q_ASSERT(m_writeTrans); | 112 | Q_ASSERT(m_writeTrans); | ||
112 | 113 | | |||
113 | m_writeTrans->removeRecursively(id, shouldDelete); | 114 | m_writeTrans->removeRecursively(id, shouldDelete); | ||
114 | } | 115 | } | ||
115 | 116 | | |||
116 | void replaceDocument(const Document& doc, DocumentOperations operations); | 117 | void replaceDocument(const Document& doc, DocumentOperations operations); | ||
117 | void setPhaseOne(quint64 id); | 118 | void setPhaseOne(quint64 id); | ||
118 | void removePhaseOne(quint64 id); | 119 | void removePhaseOne(quint64 id); | ||
119 | 120 | /** | |||
121 | * Print database content to stdout | ||||
122 | * | ||||
123 | * \p deviceID filter by device id. Negative numbers list everything but... | ||||
124 | * with \p deviceID = 0 (default) everything | ||||
125 | * is printed. | ||||
126 | * | ||||
127 | * \p simulatePurge Simulate purging operation. Only inaccessible items are printed. | ||||
128 | * | ||||
129 | * \p urlFilter Filter result urls. Default is null = Print everything. | ||||
130 | */ | ||||
131 | void list(const qint64 deviceID, | ||||
132 | const bool simulatePurge, | ||||
133 | const QSharedPointer<QRegularExpression> urlFilter | ||||
134 | ); | ||||
120 | // Debugging | 135 | // Debugging | ||
121 | void checkFsTree(); | 136 | void checkFsTree(); | ||
122 | void checkTermsDbinPostingDb(); | 137 | void checkTermsDbinPostingDb(); | ||
123 | void checkPostingDbinTermsDb(); | 138 | void checkPostingDbinTermsDb(); | ||
139 | private: | ||||
140 | /** | ||||
141 | * Basic info about database items | ||||
142 | */ | ||||
143 | struct FileInfo { | ||||
144 | quint32 deviceId; | ||||
145 | quint32 inode; | ||||
146 | QString url; | ||||
147 | bool accessible; | ||||
148 | }; | ||||
149 | /** | ||||
150 | * Create a list of \a FileInfo items. | ||||
151 | */ | ||||
152 | QVector<Transaction::FileInfo> createList( | ||||
153 | const qint64 deviceId, | ||||
154 | const bool purging, | ||||
155 | const QSharedPointer<QRegularExpression>& urlFilter | ||||
156 | ) const; | ||||
124 | 157 | | |||
125 | private: | 158 | private: | ||
126 | Transaction(const Transaction& rhs) = delete; | 159 | Transaction(const Transaction& rhs) = delete; | ||
127 | 160 | | |||
128 | const DatabaseDbis& m_dbis; | 161 | const DatabaseDbis& m_dbis; | ||
129 | MDB_txn* m_txn; | 162 | MDB_txn* m_txn; | ||
130 | MDB_env* m_env; | 163 | MDB_env* m_env; | ||
131 | WriteTransaction* m_writeTrans; | 164 | WriteTransaction* m_writeTrans; | ||
132 | 165 | | |||
133 | friend class DBState; // for testing | 166 | friend class DBState; // for testing | ||
134 | }; | 167 | }; | ||
135 | } | 168 | } | ||
136 | 169 | | |||
137 | #endif // BALOO_TRANSACTION_H | 170 | #endif // BALOO_TRANSACTION_H |