summaryrefslogtreecommitdiff
path: root/kde-frameworks/baloo/files/baloo-5.26.0-runtime-crash.patch
blob: 0ae8b9b453d419360e41b78ceaa819df154340b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Christoph Cullmann <cullmann@kde.org>
Date: Thu, 08 Sep 2016 22:00:40 +0000
Subject: fix baloo_file crash with corrupted database
X-Git-Url: http://quickgit.kde.org/?p=baloo.git&a=commitdiff&h=a03b0caa4ca1fbfc249bfc0c2730aac340bbf929
---
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
---


--- a/src/file/main.cpp
+++ b/src/file/main.cpp
@@ -82,7 +82,23 @@
     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();