[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [baloo] src/file: fix baloo_file crash with corrupted database
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2016-09-08 22:02:11
Message-ID: E1bi7Od-0002Wb-Mv () code ! kde ! org
[Download RAW message or body]

Git commit a03b0caa4ca1fbfc249bfc0c2730aac340bbf929 by Christoph Cullmann.
Committed on 08/09/2016 at 22:00.
Pushed by cullmann into branch 'master'.

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

M  +17   -1    src/file/main.cpp

http://commits.kde.org/baloo/a03b0caa4ca1fbfc249bfc0c2730aac340bbf929

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();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic