Changeset View
Changeset View
Standalone View
Standalone View
src/engine/writetransaction.h
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 34 | public: | |||
---|---|---|---|---|---|
54 | * | 54 | * | ||
55 | * This function should typically be called when there are no other ReadTransaction in process | 55 | * This function should typically be called when there are no other ReadTransaction in process | ||
56 | * as that would otherwise balloon the size of the database. | 56 | * as that would otherwise balloon the size of the database. | ||
57 | */ | 57 | */ | ||
58 | template <typename Functor> | 58 | template <typename Functor> | ||
59 | void removeRecursively(quint64 parentId, Functor shouldDelete) { | 59 | void removeRecursively(quint64 parentId, Functor shouldDelete) { | ||
60 | DocumentUrlDB docUrlDB(m_dbis.idTreeDbi, m_dbis.idFilenameDbi, m_txn); | 60 | DocumentUrlDB docUrlDB(m_dbis.idTreeDbi, m_dbis.idFilenameDbi, m_txn); | ||
61 | 61 | | |||
62 | if (shouldDelete(parentId)) { | 62 | if (!shouldDelete(parentId)) { | ||
63 | removeRecursively(parentId); | | |||
64 | return; | 63 | return; | ||
65 | } | 64 | } | ||
66 | 65 | | |||
67 | const QVector<quint64> children = docUrlDB.getChildren(parentId); | 66 | const QVector<quint64> children = docUrlDB.getChildren(parentId); | ||
68 | for (quint64 id : children) { | 67 | for (quint64 id : children) { | ||
69 | removeRecursively(id, shouldDelete); | 68 | removeRecursively(id, shouldDelete); | ||
70 | } | 69 | } | ||
70 | // refetch | ||||
71 | if (docUrlDB.getChildren(parentId).isEmpty()) { | ||||
72 | removeDocument(parentId); | ||||
73 | } | ||||
71 | } | 74 | } | ||
72 | 75 | | |||
73 | void replaceDocument(const Document& doc, DocumentOperations operations); | 76 | void replaceDocument(const Document& doc, DocumentOperations operations); | ||
74 | void commit(); | 77 | void commit(); | ||
75 | 78 | | |||
76 | bool hasChanges() const { | 79 | bool hasChanges() const { | ||
77 | return !m_pendingOperations.isEmpty(); | 80 | return !m_pendingOperations.isEmpty(); | ||
78 | } | 81 | } | ||
Show All 29 Lines |