summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-20 20:42:52 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-23 17:37:53 +0200
commit166aa563ad41c4566c02cff583df612e328d1520 (patch)
tree2acf8397e03d464dae2d451ce3b7a36d2c439691 /common/index.cpp
parent3c3c117b96f0063221889d3e896cdbadd1b36a99 (diff)
downloadsink-166aa563ad41c4566c02cff583df612e328d1520.tar.gz
sink-166aa563ad41c4566c02cff583df612e328d1520.zip
Deal with non-existing index
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/index.cpp b/common/index.cpp
index 9bb467b..a8de697 100644
--- a/common/index.cpp
+++ b/common/index.cpp
@@ -17,6 +17,10 @@ void Index::add(const QByteArray &key, const QByteArray &value)
17void Index::lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler, 17void Index::lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler,
18 const std::function<void(const Error &error)> &errorHandler) 18 const std::function<void(const Error &error)> &errorHandler)
19{ 19{
20 if (!mStorage.exists()) {
21 errorHandler(Error("index", IndexNotAvailable, "Index not existing"));
22 return;
23 }
20 mStorage.scan(key, [this, resultHandler](void *keyPtr, int keySize, void *valuePtr, int valueSize) -> bool { 24 mStorage.scan(key, [this, resultHandler](void *keyPtr, int keySize, void *valuePtr, int valueSize) -> bool {
21 resultHandler(QByteArray(static_cast<char*>(valuePtr), valueSize)); 25 resultHandler(QByteArray(static_cast<char*>(valuePtr), valueSize));
22 return true; 26 return true;