From ea4d0708e63b7dc7ee0b1cb150f1e09da1f52046 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 19 Jun 2016 20:14:54 +0200 Subject: Don't try to remove empty values from the index. Indexes don't allow empty keys, so this will always fail. --- common/indexupdater.h | 8 ++++++-- 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: void remove(const QVariant &value, const QByteArray &uid, Sink::Storage::Transaction &transaction) { - // TODO hide notfound error - Index(mIndexIdentifier, transaction).remove(value.toByteArray(), uid); + if (value.isValid()) { + const auto data = value.toByteArray(); + if (!data.isEmpty()) { + Index(mIndexIdentifier, transaction).remove(data, uid); + } + } } 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 for (const auto &property : mProperties) { const auto value = bufferAdaptor.getProperty(property); // FIXME don't always convert to byte array - Index(indexName(property), transaction).remove(getByteArray(value), identifier); + const auto data = getByteArray(value); + if (data.isEmpty()) { + Index(indexName(property), transaction).remove(data, identifier); + } } for (auto it = mSortedProperties.constBegin(); it != mSortedProperties.constEnd(); it++) { const auto propertyValue = bufferAdaptor.getProperty(it.key()); -- cgit v1.2.3