diff options
Diffstat (limited to 'common/index.cpp')
-rw-r--r-- | common/index.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/common/index.cpp b/common/index.cpp index a8de697..7e3c09e 100644 --- a/common/index.cpp +++ b/common/index.cpp | |||
@@ -9,9 +9,7 @@ Index::Index(const QString &storageRoot, const QString &name, Akonadi2::Storage: | |||
9 | 9 | ||
10 | void Index::add(const QByteArray &key, const QByteArray &value) | 10 | void Index::add(const QByteArray &key, const QByteArray &value) |
11 | { | 11 | { |
12 | mStorage.startTransaction(Akonadi2::Storage::ReadWrite); | 12 | mStorage.createTransaction(Akonadi2::Storage::ReadWrite).write(key, value); |
13 | mStorage.write(key.data(), key.size(), value.data(), value.size()); | ||
14 | mStorage.commitTransaction(); | ||
15 | } | 13 | } |
16 | 14 | ||
17 | void Index::lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler, | 15 | void Index::lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler, |
@@ -21,8 +19,8 @@ void Index::lookup(const QByteArray &key, const std::function<void(const QByteAr | |||
21 | errorHandler(Error("index", IndexNotAvailable, "Index not existing")); | 19 | errorHandler(Error("index", IndexNotAvailable, "Index not existing")); |
22 | return; | 20 | return; |
23 | } | 21 | } |
24 | mStorage.scan(key, [this, resultHandler](void *keyPtr, int keySize, void *valuePtr, int valueSize) -> bool { | 22 | mStorage.createTransaction(Akonadi2::Storage::ReadOnly).scan(key, [this, resultHandler](const QByteArray &key, const QByteArray &value) -> bool { |
25 | resultHandler(QByteArray(static_cast<char*>(valuePtr), valueSize)); | 23 | resultHandler(value); |
26 | return true; | 24 | return true; |
27 | }, | 25 | }, |
28 | [errorHandler](const Akonadi2::Storage::Error &error) { | 26 | [errorHandler](const Akonadi2::Storage::Error &error) { |