Commit 6934738a authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

StorageJanitor: skip search index check of Collections without mimetype

Without mimetype we don't know which search store to look into,
but it also means that the Indexing Agent should not be able to
index it, so there should be no invalid indexed items.

BUG: 379153
parent 0c0c2824
...@@ -716,6 +716,7 @@ void StorageJanitor::findOprhanSearchIndexEntries() ...@@ -716,6 +716,7 @@ void StorageJanitor::findOprhanSearchIndexEntries()
QueryBuilder qb(Collection::tableName(), QueryBuilder::Select); QueryBuilder qb(Collection::tableName(), QueryBuilder::Select);
qb.addSortColumn(Collection::idColumn(), Query::Ascending); qb.addSortColumn(Collection::idColumn(), Query::Ascending);
qb.addColumn(Collection::idColumn()); qb.addColumn(Collection::idColumn());
qb.addColumn(Collection::isVirtualColumn());
if (!qb.exec()) { if (!qb.exec()) {
inform("Failed to query collections, skipping test"); inform("Failed to query collections, skipping test");
return; return;
...@@ -733,6 +734,12 @@ void StorageJanitor::findOprhanSearchIndexEntries() ...@@ -733,6 +734,12 @@ void StorageJanitor::findOprhanSearchIndexEntries()
QSqlQuery query = qb.query(); QSqlQuery query = qb.query();
while (query.next()) { while (query.next()) {
const qint64 colId = query.value(0).toLongLong(); const qint64 colId = query.value(0).toLongLong();
// Skip virtual collections, they are not indexed
if (query.value(1).toBool()) {
inform(QStringLiteral("Skipping virtual Collection %1").arg(colId));
continue;
}
inform(QStringLiteral("Checking Collection %1 search index...").arg(colId)); inform(QStringLiteral("Checking Collection %1 search index...").arg(colId));
SearchRequest req("StorageJanitor"); SearchRequest req("StorageJanitor");
req.setStoreResults(true); req.setStoreResults(true);
...@@ -743,6 +750,11 @@ void StorageJanitor::findOprhanSearchIndexEntries() ...@@ -743,6 +750,11 @@ void StorageJanitor::findOprhanSearchIndexEntries()
Collection col; Collection col;
col.setId(colId); col.setId(colId);
const auto colMts = col.mimeTypes(); const auto colMts = col.mimeTypes();
if (colMts.isEmpty()) {
// No mimetypes means we don't know which search store to look into,
// skip it.
continue;
}
for (const auto &mt : colMts) { for (const auto &mt : colMts) {
mts << mt.name(); mts << mt.name();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment