diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-09-29 00:52:07 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-09-29 00:52:07 +0200 |
commit | c3f6e72c2d46906a4699127b558ca248729ce577 (patch) | |
tree | a2066e43b45a01226e19bbb309fabf7064018a06 /common/storage_common.cpp | |
parent | b43c422a2b1b899ce5ac27a0bc381e8a49f05d86 (diff) | |
download | sink-c3f6e72c2d46906a4699127b558ca248729ce577.tar.gz sink-c3f6e72c2d46906a4699127b558ca248729ce577.zip |
Revision cleanup
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r-- | common/storage_common.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 28fb4c2..dc02aec 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -74,6 +74,48 @@ qint64 Storage::maxRevision(const Akonadi2::Storage::Transaction &transaction) | |||
74 | return r; | 74 | return r; |
75 | } | 75 | } |
76 | 76 | ||
77 | QByteArray Storage::getUidFromRevision(const Akonadi2::Storage::Transaction &transaction, qint64 revision) | ||
78 | { | ||
79 | QByteArray uid; | ||
80 | transaction.openDatabase("revisions").scan(QByteArray::number(revision), [&](const QByteArray &, const QByteArray &value) -> bool { | ||
81 | uid = value; | ||
82 | return false; | ||
83 | }, [](const Error &error){ | ||
84 | if (error.code != ErrorCodes::NotFound) { | ||
85 | //FIXME | ||
86 | // defaultErrorHandler()(error); | ||
87 | } | ||
88 | }); | ||
89 | return uid; | ||
90 | } | ||
91 | |||
92 | QByteArray Storage::getTypeFromRevision(const Akonadi2::Storage::Transaction &transaction, qint64 revision) | ||
93 | { | ||
94 | QByteArray type; | ||
95 | transaction.openDatabase("revisionType").scan(QByteArray::number(revision), [&](const QByteArray &, const QByteArray &value) -> bool { | ||
96 | type = value; | ||
97 | return false; | ||
98 | }, [](const Error &error){ | ||
99 | if (error.code != ErrorCodes::NotFound) { | ||
100 | //FIXME | ||
101 | // defaultErrorHandler()(error); | ||
102 | } | ||
103 | }); | ||
104 | return type; | ||
105 | } | ||
106 | |||
107 | void Storage::recordRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision, const QByteArray &uid, const QByteArray &type) | ||
108 | { | ||
109 | //TODO use integerkeys | ||
110 | transaction.openDatabase("revisions").write(QByteArray::number(revision), uid); | ||
111 | transaction.openDatabase("revisionType").write(QByteArray::number(revision), type); | ||
112 | } | ||
113 | |||
114 | void Storage::removeRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision) | ||
115 | { | ||
116 | transaction.openDatabase("revisions").remove(QByteArray::number(revision)); | ||
117 | } | ||
118 | |||
77 | bool Storage::isInternalKey(const char *key) | 119 | bool Storage::isInternalKey(const char *key) |
78 | { | 120 | { |
79 | return key && strncmp(key, s_internalPrefix, s_internalPrefixSize) == 0; | 121 | return key && strncmp(key, s_internalPrefix, s_internalPrefixSize) == 0; |