diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-19 20:14:54 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-19 20:14:54 +0200 |
commit | ea4d0708e63b7dc7ee0b1cb150f1e09da1f52046 (patch) | |
tree | cde644a4f18f2a27b9a3d511a40c792147be9a2f | |
parent | 8f06f8a31682760b385ba740db28429d7914730a (diff) | |
download | sink-ea4d0708e63b7dc7ee0b1cb150f1e09da1f52046.tar.gz sink-ea4d0708e63b7dc7ee0b1cb150f1e09da1f52046.zip |
Don't try to remove empty values from the index.
Indexes don't allow empty keys, so this will always fail.
-rw-r--r-- | common/indexupdater.h | 8 | ||||
-rw-r--r-- | common/typeindex.cpp | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/common/indexupdater.h b/common/indexupdater.h index 936d03a..79499c3 100644 --- a/common/indexupdater.h +++ b/common/indexupdater.h | |||
@@ -55,8 +55,12 @@ private: | |||
55 | 55 | ||
56 | void remove(const QVariant &value, const QByteArray &uid, Sink::Storage::Transaction &transaction) | 56 | void remove(const QVariant &value, const QByteArray &uid, Sink::Storage::Transaction &transaction) |
57 | { | 57 | { |
58 | // TODO hide notfound error | 58 | if (value.isValid()) { |
59 | Index(mIndexIdentifier, transaction).remove(value.toByteArray(), uid); | 59 | const auto data = value.toByteArray(); |
60 | if (!data.isEmpty()) { | ||
61 | Index(mIndexIdentifier, transaction).remove(data, uid); | ||
62 | } | ||
63 | } | ||
60 | } | 64 | } |
61 | 65 | ||
62 | QByteArray mIndexIdentifier; | 66 | QByteArray mIndexIdentifier; |
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index fca083c..8d1b7f3 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -124,7 +124,10 @@ void TypeIndex::remove(const QByteArray &identifier, const Sink::ApplicationDoma | |||
124 | for (const auto &property : mProperties) { | 124 | for (const auto &property : mProperties) { |
125 | const auto value = bufferAdaptor.getProperty(property); | 125 | const auto value = bufferAdaptor.getProperty(property); |
126 | // FIXME don't always convert to byte array | 126 | // FIXME don't always convert to byte array |
127 | Index(indexName(property), transaction).remove(getByteArray(value), identifier); | 127 | const auto data = getByteArray(value); |
128 | if (data.isEmpty()) { | ||
129 | Index(indexName(property), transaction).remove(data, identifier); | ||
130 | } | ||
128 | } | 131 | } |
129 | for (auto it = mSortedProperties.constBegin(); it != mSortedProperties.constEnd(); it++) { | 132 | for (auto it = mSortedProperties.constBegin(); it != mSortedProperties.constEnd(); it++) { |
130 | const auto propertyValue = bufferAdaptor.getProperty(it.key()); | 133 | const auto propertyValue = bufferAdaptor.getProperty(it.key()); |