Changeset View
Changeset View
Standalone View
Standalone View
src/engine/transaction.cpp
Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Line(s) | 248 | { | |||
---|---|---|---|---|---|
249 | Q_ASSERT(m_txn); | 249 | Q_ASSERT(m_txn); | ||
250 | Q_ASSERT(doc.id() > 0); | 250 | Q_ASSERT(doc.id() > 0); | ||
251 | Q_ASSERT(m_writeTrans); | 251 | Q_ASSERT(m_writeTrans); | ||
252 | Q_ASSERT_X(hasDocument(doc.id()), "Transaction::replaceDocument", "Document does not exist"); | 252 | Q_ASSERT_X(hasDocument(doc.id()), "Transaction::replaceDocument", "Document does not exist"); | ||
253 | 253 | | |||
254 | m_writeTrans->replaceDocument(doc, operations); | 254 | m_writeTrans->replaceDocument(doc, operations); | ||
255 | } | 255 | } | ||
256 | 256 | | |||
257 | void Transaction::pruneFsTree() | ||||
258 | { | ||||
259 | DocumentUrlDB docUrlDb(m_dbis.idTreeDbi, m_dbis.idFilenameDbi, m_txn); | ||||
260 | auto map = docUrlDb.toTestMap(); | ||||
261 | | ||||
262 | QTextStream out(stdout); | ||||
263 | for (quint64 id: map.keys()) { | ||||
264 | QByteArray url = docUrlDb.get(id); | ||||
michaelh: This should go to stderr so only pruned files go to stdout | |||||
265 | if (!QFileInfo::exists(url)) { | ||||
266 | removeDocument(id); | ||||
267 | out << "Purged " << id << " " << url << endl; | ||||
268 | } | ||||
269 | } | ||||
michaelh: You need to `commit()` here, otherwise changes will be lost. | |||||
270 | } | ||||
Place this at the end of the loop and also print url, please. E.g. out << "Removed" << id << ":" << url; would be easily parseable. So one could catch stdout with balooctl pruneDb | tr '-d:' -f2 >removed_files.lst michaelh: Place this at the end of the loop and also print url, please. E.g. `out << "Removed" << id << "… | |||||
271 | | ||||
michaelh: Can we or should we check the result of the operation here? | |||||
smithjd: removeDocument() is void. | |||||
257 | void Transaction::commit() | 272 | void Transaction::commit() | ||
258 | { | 273 | { | ||
259 | Q_ASSERT(m_txn); | 274 | Q_ASSERT(m_txn); | ||
260 | Q_ASSERT(m_writeTrans); | 275 | Q_ASSERT(m_writeTrans); | ||
261 | 276 | | |||
michaelh: Same as above | |||||
262 | m_writeTrans->commit(); | 277 | m_writeTrans->commit(); | ||
263 | delete m_writeTrans; | 278 | delete m_writeTrans; | ||
264 | m_writeTrans = nullptr; | 279 | m_writeTrans = nullptr; | ||
265 | 280 | | |||
266 | int rc = mdb_txn_commit(m_txn); | 281 | int rc = mdb_txn_commit(m_txn); | ||
267 | Q_ASSERT_X(rc == 0, "Transaction::commit", mdb_strerror(rc)); | 282 | Q_ASSERT_X(rc == 0, "Transaction::commit", mdb_strerror(rc)); | ||
268 | 283 | | |||
269 | m_txn = nullptr; | 284 | m_txn = nullptr; | ||
▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines |
This should go to stderr so only pruned files go to stdout