summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-10 23:06:33 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-10 23:06:33 +0200
commit13cd7cff06f1e4e51fb2a5d16b57662292c80b77 (patch)
tree7bc2a936114fc6a4874c1bbc117d37b6d2e7c563 /common/index.cpp
parentcf0d0fd0c6afaeb9cdee276ee0305126b66604b3 (diff)
downloadsink-13cd7cff06f1e4e51fb2a5d16b57662292c80b77.tar.gz
sink-13cd7cff06f1e4e51fb2a5d16b57662292c80b77.zip
Use new api in index.
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp8
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
10void Index::add(const QByteArray &key, const QByteArray &value) 10void 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
17void Index::lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler, 15void 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) {