diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/index.cpp | 4 | ||||
-rw-r--r-- | common/index.h | 4 |
2 files changed, 8 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) | |||
17 | void Index::lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler, | 17 | void 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; |
diff --git a/common/index.h b/common/index.h index 3cd7cc8..08b499f 100644 --- a/common/index.h +++ b/common/index.h | |||
@@ -11,6 +11,10 @@ | |||
11 | class Index | 11 | class Index |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | enum ErrorCodes { | ||
15 | IndexNotAvailable = -1 | ||
16 | }; | ||
17 | |||
14 | class Error | 18 | class Error |
15 | { | 19 | { |
16 | public: | 20 | public: |