File 0001-fix-baloo_file-crash-with-corrupted-database.patch of Package baloo5

From a03b0caa4ca1fbfc249bfc0c2730aac340bbf929 Mon Sep 17 00:00:00 2001
From: Christoph Cullmann <cullmann@kde.org>
Date: Fri, 9 Sep 2016 00:00:40 +0200
Subject: [PATCH 01/13] fix baloo_file crash with corrupted database

CHANGELOG: Handle corruption of index database for baloo_file, try to recreate the database or abort if that fails.

REVIEW: 128865
---
 src/file/main.cpp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/file/main.cpp b/src/file/main.cpp
index 9410635..52c42e9 100644
--- a/src/file/main.cpp
+++ b/src/file/main.cpp
@@ -82,7 +82,23 @@ int main(int argc, char** argv)
     QFile::remove(path + "/index-lock");
 
     Baloo::Database *db = Baloo::globalDatabaseInstance();
-    db->open(Baloo::Database::CreateDatabase);
+
+    /**
+     * try to open, if that fails, try to unlink the index db and retry
+     */
+    if (!db->open(Baloo::Database::CreateDatabase)) {
+        // delete old stuff, set to initial run!
+        qWarning() << "Failed to create database, removing corrupted database.";
+        QFile::remove(path + "/index");
+        QFile::remove(path + "/index-lock");
+        indexerConfig.setInitialRun(true);
+
+        // try to create now after cleanup, if still no works => fail
+        if (!db->open(Baloo::Database::CreateDatabase)) {
+            qWarning() << "Failed to create database after deleting corrupted one.";
+            return 1;
+        }
+    }
 
     Baloo::MainHub hub(db, &indexerConfig);
     return app.exec();
-- 
2.10.0