Changeset View
Changeset View
Standalone View
Standalone View
src/engine/writetransaction.cpp
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 158 | { | |||
---|---|---|---|---|---|
162 | for (quint64 id : children) { | 162 | for (quint64 id : children) { | ||
163 | if (id) { | 163 | if (id) { | ||
164 | removeRecursively(id); | 164 | removeRecursively(id); | ||
165 | } | 165 | } | ||
166 | } | 166 | } | ||
167 | removeDocument(parentId); | 167 | removeDocument(parentId); | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | bool WriteTransaction::removeRecursively(quint64 parentId, std::function<bool(quint64)> shouldDelete) | ||||
171 | { | ||||
172 | DocumentUrlDB docUrlDB(m_dbis.idTreeDbi, m_dbis.idFilenameDbi, m_txn); | ||||
173 | | ||||
174 | if (parentId && !shouldDelete(parentId)) { | ||||
175 | return false; | ||||
176 | } | ||||
177 | | ||||
178 | bool isEmpty = true; | ||||
179 | const QVector<quint64> children = docUrlDB.getChildren(parentId); | ||||
180 | for (quint64 id : children) { | ||||
181 | isEmpty &= removeRecursively(id, shouldDelete); | ||||
182 | } | ||||
183 | // refetch | ||||
184 | if (isEmpty && docUrlDB.getChildren(parentId).isEmpty()) { | ||||
185 | removeDocument(parentId); | ||||
186 | return true; | ||||
187 | } | ||||
188 | return false; | ||||
189 | } | ||||
190 | | ||||
170 | void WriteTransaction::replaceDocument(const Document& doc, DocumentOperations operations) | 191 | void WriteTransaction::replaceDocument(const Document& doc, DocumentOperations operations) | ||
171 | { | 192 | { | ||
172 | DocumentDB documentTermsDB(m_dbis.docTermsDbi, m_txn); | 193 | DocumentDB documentTermsDB(m_dbis.docTermsDbi, m_txn); | ||
173 | DocumentDB documentXattrTermsDB(m_dbis.docXattrTermsDbi, m_txn); | 194 | DocumentDB documentXattrTermsDB(m_dbis.docXattrTermsDbi, m_txn); | ||
174 | DocumentDB documentFileNameTermsDB(m_dbis.docFilenameTermsDbi, m_txn); | 195 | DocumentDB documentFileNameTermsDB(m_dbis.docFilenameTermsDbi, m_txn); | ||
175 | DocumentTimeDB docTimeDB(m_dbis.docTimeDbi, m_txn); | 196 | DocumentTimeDB docTimeDB(m_dbis.docTimeDbi, m_txn); | ||
176 | DocumentDataDB docDataDB(m_dbis.docDataDbi, m_txn); | 197 | DocumentDataDB docDataDB(m_dbis.docDataDbi, m_txn); | ||
177 | DocumentIdDB contentIndexingDB(m_dbis.contentIndexingDbi, m_txn); | 198 | DocumentIdDB contentIndexingDB(m_dbis.contentIndexingDbi, m_txn); | ||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |