diff options
Diffstat (limited to 'kde-frameworks/baloo/files')
5 files changed, 644 insertions, 0 deletions
diff --git a/kde-frameworks/baloo/files/baloo-5.26.0-dont-corrupt.patch b/kde-frameworks/baloo/files/baloo-5.26.0-dont-corrupt.patch new file mode 100644 index 000000000000..1dc1f1f19fc1 --- /dev/null +++ b/kde-frameworks/baloo/files/baloo-5.26.0-dont-corrupt.patch @@ -0,0 +1,193 @@ +From: Christoph Cullmann <cullmann@kde.org> +Date: Sun, 11 Sep 2016 21:36:27 +0000 +Subject: Open baloo lmdb database read-only beside in baloo_file/baloo_file_extractor + balooctl (for some commands) + unit tests +X-Git-Url: http://quickgit.kde.org/?p=baloo.git&a=commitdiff&h=02047b524a176da447d8c96e15c7e2abae8339ae +--- +Open baloo lmdb database read-only beside in baloo_file/baloo_file_extractor + balooctl (for some commands) + unit tests + +At the moment, any application that uses baloo can corrupt the db. +Now, only the things that need to write to it open it with read-write. +This only works as long as the library exposes only read-only things like Query/... + +REVIEW: 128892 +--- + + +--- a/src/engine/database.cpp ++++ b/src/engine/database.cpp +@@ -79,7 +79,7 @@ + } + QFileInfo indexInfo(dir, QStringLiteral("index")); + +- if (mode == OpenDatabase && !indexInfo.exists()) { ++ if ((mode != CreateDatabase) && !indexInfo.exists()) { + return false; + } + +@@ -117,7 +117,7 @@ + + // The directory needs to be created before opening the environment + QByteArray arr = QFile::encodeName(indexInfo.absoluteFilePath()); +- rc = mdb_env_open(m_env, arr.constData(), MDB_NOSUBDIR | MDB_NOMEMINIT, 0664); ++ rc = mdb_env_open(m_env, arr.constData(), MDB_NOSUBDIR | MDB_NOMEMINIT | ((mode == ReadOnlyDatabase) ? MDB_RDONLY : 0), 0664); + if (rc) { + mdb_env_close(m_env); + m_env = nullptr; +@@ -136,7 +136,7 @@ + // Individual Databases + // + MDB_txn* txn; +- if (mode == OpenDatabase) { ++ if (mode != CreateDatabase) { + int rc = mdb_txn_begin(m_env, NULL, MDB_RDONLY, &txn); + Q_ASSERT_X(rc == 0, "Database::transaction ro begin", mdb_strerror(rc)); + if (rc) { + +--- a/src/engine/database.h ++++ b/src/engine/database.h +@@ -49,8 +49,20 @@ + * Database open mode + */ + enum OpenMode { ++ /** ++ * Create + open read-write dabase. ++ */ + CreateDatabase, +- OpenDatabase ++ ++ /** ++ * Read-Write Database, only works if database exists. ++ */ ++ ReadWriteDatabase, ++ ++ /** ++ * Read-Only Database, only works if database exists. ++ */ ++ ReadOnlyDatabase + }; + + /** + +--- a/src/file/extractor/app.cpp ++++ b/src/file/extractor/app.cpp +@@ -55,7 +55,7 @@ + void App::slotNewInput() + { + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadWriteDatabase)) { + qCritical() << "Failed to open the database"; + exit(1); + } + +--- a/src/lib/file.cpp ++++ b/src/lib/file.cpp +@@ -96,7 +96,7 @@ + } + + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadOnlyDatabase)) { + return false; + } + + +--- a/src/lib/searchstore.cpp ++++ b/src/lib/searchstore.cpp +@@ -48,7 +48,7 @@ + : m_db(0) + { + m_db = globalDatabaseInstance(); +- if (!m_db->open(Database::OpenDatabase)) { ++ if (!m_db->open(Database::ReadOnlyDatabase)) { + m_db = 0; + } + + +--- a/src/lib/taglistjob.cpp ++++ b/src/lib/taglistjob.cpp +@@ -46,7 +46,7 @@ + void TagListJob::start() + { + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadOnlyDatabase)) { + setError(UserDefinedError); + setErrorText(QStringLiteral("Failed to open the database")); + emitResult(); + +--- a/src/qml/experimental/monitor.cpp ++++ b/src/qml/experimental/monitor.cpp +@@ -126,7 +126,7 @@ + void Monitor::fetchTotalFiles() + { + Baloo::Database *db = Baloo::globalDatabaseInstance(); +- if (db->open(Baloo::Database::OpenDatabase)) { ++ if (db->open(Baloo::Database::ReadOnlyDatabase)) { + Baloo::Transaction tr(db, Baloo::Transaction::ReadOnly); + m_totalFiles = tr.size(); + m_filesIndexed = tr.size() - tr.phaseOneSize(); + +--- a/src/tools/balooctl/main.cpp ++++ b/src/tools/balooctl/main.cpp +@@ -191,7 +191,7 @@ + } + + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadWriteDatabase)) { + out << "Baloo Index could not be opened\n"; + return 1; + } +@@ -230,7 +230,7 @@ + } + + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadWriteDatabase)) { + out << "Baloo Index could not be opened\n"; + return 1; + } +@@ -260,7 +260,7 @@ + + if (command == QStringLiteral("indexSize")) { + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadOnlyDatabase)) { + out << "Baloo Index could not be opened\n"; + return 1; + } +@@ -311,7 +311,7 @@ + + if (command == QStringLiteral("checkDb")) { + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadOnlyDatabase)) { + out << "Baloo Index could not be opened\n"; + return 1; + } + +--- a/src/tools/balooctl/statuscommand.cpp ++++ b/src/tools/balooctl/statuscommand.cpp +@@ -56,7 +56,7 @@ + } + + Database *db = globalDatabaseInstance(); +- if (!db->open(Database::OpenDatabase)) { ++ if (!db->open(Database::ReadOnlyDatabase)) { + out << i18n("Baloo Index could not be opened") << endl; + return 1; + } + +--- a/src/tools/balooshow/main.cpp ++++ b/src/tools/balooshow/main.cpp +@@ -101,7 +101,7 @@ + QString text; + + Baloo::Database *db = Baloo::globalDatabaseInstance(); +- if (!db->open(Baloo::Database::OpenDatabase)) { ++ if (!db->open(Baloo::Database::ReadOnlyDatabase)) { + stream << i18n("The Baloo index could not be opened. Please run \"balooctl status\" to see if Baloo is enabled and working.") + << endl; + return 1; + diff --git a/kde-frameworks/baloo/files/baloo-5.26.0-runtime-crash.patch b/kde-frameworks/baloo/files/baloo-5.26.0-runtime-crash.patch new file mode 100644 index 000000000000..0ae8b9b453d4 --- /dev/null +++ b/kde-frameworks/baloo/files/baloo-5.26.0-runtime-crash.patch @@ -0,0 +1,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(); + diff --git a/kde-frameworks/baloo/files/baloo-5.26.0-size-limit.patch b/kde-frameworks/baloo/files/baloo-5.26.0-size-limit.patch new file mode 100644 index 000000000000..6739a2754b63 --- /dev/null +++ b/kde-frameworks/baloo/files/baloo-5.26.0-size-limit.patch @@ -0,0 +1,118 @@ +From: Christoph Cullmann <cullmann@kde.org> +Date: Sun, 11 Sep 2016 16:54:58 +0000 +Subject: Increase size limit of baloo index for 64-bit machines +X-Git-Url: http://quickgit.kde.org/?p=baloo.git&a=commitdiff&h=b0890aca71aa4f0fdabe65ee7b7fbd0bc844d8b8 +--- +Increase size limit of baloo index for 64-bit machines + +CHANGELOG: On 64-bit systems baloo allows now > 5 GB index storage. + +Increase size limit of baloo index for 64-bit machines to avoid crashs after > 5GB of index size. +(Better would be additional out-of-space handling, but ATM baloo has zero checks for that) + +The size limit for 32-bit is still 1GB, like before (there was a silent overflow from 5GB to 1GB in the computation), people with large homes will still get random segfaults on 32-bit. + +Patch based on patch from Hao Zhang, Bug 364475 + +REVIEW: 128885 +BUG: 364475 +--- + + +--- a/src/engine/database.cpp ++++ b/src/engine/database.cpp +@@ -93,8 +93,18 @@ + return false; + } + ++ /** ++ * maximal number of allowed named databases, must match number of databases we create below ++ * each additional one leads to overhead ++ */ + mdb_env_set_maxdbs(m_env, 12); +- mdb_env_set_mapsize(m_env, static_cast<size_t>(1024) * 1024 * 1024 * 5); // 5 gb ++ ++ /** ++ * size limit for database == size limit of mmap ++ * use 1 GB on 32-bit, use 256 GB on 64-bit ++ */ ++ const size_t maximalSizeInBytes = size_t((sizeof(size_t) == 4) ? 1 : 256) * size_t(1024) * size_t(1024) * size_t(1024); ++ mdb_env_set_mapsize(m_env, maximalSizeInBytes); + + // The directory needs to be created before opening the environment + QByteArray arr = QFile::encodeName(indexInfo.absoluteFilePath()); + +--- a/src/engine/databasesize.h ++++ b/src/engine/databasesize.h +@@ -31,30 +31,30 @@ + * This is the size which is computed with all the pages used from all the + * individual database pages + */ +- uint expectedSize; ++ size_t expectedSize; + + /** + * This is the size based on the MDB_env and the total number of pages used + */ +- uint actualSize; ++ size_t actualSize; + +- uint postingDb; +- uint positionDb; ++ size_t postingDb; ++ size_t positionDb; + +- uint docTerms; +- uint docFilenameTerms; +- uint docXattrTerms; ++ size_t docTerms; ++ size_t docFilenameTerms; ++ size_t docXattrTerms; + +- uint idTree; +- uint idFilename; ++ size_t idTree; ++ size_t idFilename; + +- uint docTime; +- uint docData; ++ size_t docTime; ++ size_t docData; + +- uint contentIndexingIds; +- uint failedIds; ++ size_t contentIndexingIds; ++ size_t failedIds; + +- uint mtimeDb; ++ size_t mtimeDb; + }; + + } + +--- a/src/engine/transaction.cpp ++++ b/src/engine/transaction.cpp +@@ -402,7 +402,7 @@ + // + // File Size + // +-static uint dbiSize(MDB_txn* txn, MDB_dbi dbi) ++static size_t dbiSize(MDB_txn* txn, MDB_dbi dbi) + { + MDB_stat stat; + mdb_stat(txn, dbi, &stat); + +--- a/src/tools/balooctl/statuscommand.cpp ++++ b/src/tools/balooctl/statuscommand.cpp +@@ -92,8 +92,8 @@ + + const QString path = fileIndexDbPath(); + +- QFileInfo indexInfo(path + QLatin1String("/index")); +- quint32 size = indexInfo.size(); ++ const QFileInfo indexInfo(path + QLatin1String("/index")); ++ const auto size = indexInfo.size(); + KFormat format(QLocale::system()); + if (size) { + out << "Current size of index is " << format.formatByteSize(size, 2) << endl; + diff --git a/kde-frameworks/baloo/files/baloo-5.26.0-thread-safety.patch b/kde-frameworks/baloo/files/baloo-5.26.0-thread-safety.patch new file mode 100644 index 000000000000..11965f5ef3fd --- /dev/null +++ b/kde-frameworks/baloo/files/baloo-5.26.0-thread-safety.patch @@ -0,0 +1,253 @@ +From: Christoph Cullmann <cullmann@kde.org> +Date: Sun, 11 Sep 2016 18:24:40 +0000 +Subject: Make e.g. Baloo::Query thread safe. +X-Git-Url: http://quickgit.kde.org/?p=baloo.git&a=commitdiff&h=e34da150d82a57cf417a59b8b632b2fecb32a6f7 +--- +Make e.g. Baloo::Query thread safe. + +lmdb itself is thread safe (e.g. you can use the same env in multiple threads). +Unfortunately, the Baloo:atabase itself not, as open() might race against other open calls (we have one unique db object in baloo). + +=> add non-recursive mutex (recursive mutex not needed, one just must avoid to call isOpen() or path() inside open, that is done, else no unit test works). + +REVIEW: 128890 +--- +Merged with commits +988e5feb5de64ed25337fe2ff9b494eb30b15b47 +54f7363048c7db41f63c85f637911a5598c30e9e +377e62b0307839edb0245d65381a3f55f594ae4e +--- + +--- a/src/engine/database.cpp ++++ b/src/engine/database.cpp +@@ -1,6 +1,7 @@ + /* + This file is part of the KDE Baloo project. + * Copyright (C) 2015 Vishesh Handa <vhanda@kde.org> ++ * Copyright (C) 2016 Christoph Cullmann <cullmann@kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -43,23 +44,31 @@ + #include <QFile> + #include <QFileInfo> + #include <QDir> ++#include <QMutexLocker> + + using namespace Baloo; + + Database::Database(const QString& path) + : m_path(path) +- , m_env(0) ++ , m_env(nullptr) + { + } + + Database::~Database() + { +- mdb_env_close(m_env); ++ // try only to close if we did open the DB successfully ++ if (m_env) { ++ mdb_env_close(m_env); ++ m_env = nullptr; ++ } + } + + bool Database::open(OpenMode mode) + { +- if (isOpen()) { ++ QMutexLocker locker(&m_mutex); ++ ++ // nop if already open! ++ if (m_env) { + return true; + } + +@@ -89,7 +98,7 @@ + + int rc = mdb_env_create(&m_env); + if (rc) { +- m_env = 0; ++ m_env = nullptr; + return false; + } + +@@ -110,7 +119,8 @@ + QByteArray arr = QFile::encodeName(indexInfo.absoluteFilePath()); + rc = mdb_env_open(m_env, arr.constData(), MDB_NOSUBDIR | MDB_NOMEMINIT, 0664); + if (rc) { +- m_env = 0; ++ mdb_env_close(m_env); ++ m_env = nullptr; + return false; + } + +@@ -118,6 +128,7 @@ + Q_ASSERT_X(rc == 0, "Database::open reader_check", mdb_strerror(rc)); + if (rc) { + mdb_env_close(m_env); ++ m_env = nullptr; + return false; + } + +@@ -129,9 +140,8 @@ + int rc = mdb_txn_begin(m_env, NULL, MDB_RDONLY, &txn); + Q_ASSERT_X(rc == 0, "Database::transaction ro begin", mdb_strerror(rc)); + if (rc) { +- mdb_txn_abort(txn); + mdb_env_close(m_env); +- m_env = 0; ++ m_env = nullptr; + return false; + } + +@@ -157,7 +167,7 @@ + if (!m_dbis.isValid()) { + mdb_txn_abort(txn); + mdb_env_close(m_env); +- m_env = 0; ++ m_env = nullptr; + return false; + } + +@@ -165,16 +175,15 @@ + Q_ASSERT_X(rc == 0, "Database::transaction ro commit", mdb_strerror(rc)); + if (rc) { + mdb_env_close(m_env); +- m_env = 0; ++ m_env = nullptr; + return false; + } + } else { + int rc = mdb_txn_begin(m_env, NULL, 0, &txn); + Q_ASSERT_X(rc == 0, "Database::transaction begin", mdb_strerror(rc)); + if (rc) { +- mdb_txn_abort(txn); + mdb_env_close(m_env); +- m_env = 0; ++ m_env = nullptr; + return false; + } + +@@ -200,7 +209,7 @@ + if (!m_dbis.isValid()) { + mdb_txn_abort(txn); + mdb_env_close(m_env); +- m_env = 0; ++ m_env = nullptr; + return false; + } + +@@ -208,16 +217,24 @@ + Q_ASSERT_X(rc == 0, "Database::transaction commit", mdb_strerror(rc)); + if (rc) { + mdb_env_close(m_env); +- m_env = 0; ++ m_env = nullptr; + return false; + } + } + ++ Q_ASSERT(m_env); + return true; + } + ++bool Database::isOpen() const ++{ ++ QMutexLocker locker(&m_mutex); ++ return m_env != 0; ++} ++ + QString Database::path() const + { ++ QMutexLocker locker(&m_mutex); + return m_path; + } + +--- a/src/engine/database.h ++++ b/src/engine/database.h +@@ -1,6 +1,7 @@ + /* + This file is part of the KDE Baloo project. + * Copyright (C) 2015 Vishesh Handa <vhanda@kde.org> ++ * Copyright (C) 2016 Christoph Cullmann <cullmann@kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -21,6 +22,8 @@ + #ifndef BALOO_DATABASE_H + #define BALOO_DATABASE_H + ++#include <QMutex> ++ + #include "document.h" + #include "databasedbis.h" + +@@ -31,21 +34,56 @@ + class BALOO_ENGINE_EXPORT Database + { + public: ++ /** ++ * Init database for given DB path, will not open it. ++ * @param path db path ++ */ + explicit Database(const QString& path); ++ ++ /** ++ * Destruct db, might close it, if opened. ++ */ + ~Database(); + +- QString path() const; +- ++ /** ++ * Database open mode ++ */ + enum OpenMode { + CreateDatabase, + OpenDatabase + }; ++ ++ /** ++ * Open database in given mode. ++ * Nop after open was done (even if mode differs). ++ * There is no close as this would invalidate the database for all threads using it. ++ * @param mode create or open only? ++ * @return success? ++ */ + bool open(OpenMode mode); + +- bool isOpen() const { return m_env != 0; } ++ /** ++ * Is database open? ++ * @return database open? ++ */ ++ bool isOpen() const; ++ ++ /** ++ * Path to database. ++ * @return database path ++ */ ++ QString path() const; + + private: +- QString m_path; ++ /** ++ * serialize access, as open might be called from multiple threads ++ */ ++ mutable QMutex m_mutex; ++ ++ /** ++ * database path ++ */ ++ const QString m_path; + + MDB_env* m_env; + DatabaseDbis m_dbis; +@@ -56,6 +94,5 @@ + }; + } + +- + #endif // BALOO_DATABASE_H + diff --git a/kde-frameworks/baloo/files/baloo-5.26.0-zerotimestamp-crash.patch b/kde-frameworks/baloo/files/baloo-5.26.0-zerotimestamp-crash.patch new file mode 100644 index 000000000000..7e666137861e --- /dev/null +++ b/kde-frameworks/baloo/files/baloo-5.26.0-zerotimestamp-crash.patch @@ -0,0 +1,39 @@ +From: Christoph Cullmann <cullmann@kde.org> +Date: Sun, 11 Sep 2016 16:48:53 +0000 +Subject: allow ctime/mtime == 0 +X-Git-Url: http://quickgit.kde.org/?p=baloo.git&a=commitdiff&h=628daced19b88d0c537736a14aea3287a4662609 +--- +allow ctime/mtime == 0 + +Fix that baloo is instant killed by any file with timestamp 0. (which is OK and can easily happen after unpacking some zip/tar/..) + +REVIEW: 128887 +BUG: 355238 +--- + + +--- a/src/engine/documenttimedb.cpp ++++ b/src/engine/documenttimedb.cpp +@@ -58,8 +58,6 @@ + void DocumentTimeDB::put(quint64 docId, const TimeInfo& info) + { + Q_ASSERT(docId > 0); +- Q_ASSERT(info.mTime); +- Q_ASSERT(info.cTime); + + MDB_val key; + key.mv_size = sizeof(quint64); + +--- a/src/engine/writetransaction.cpp ++++ b/src/engine/writetransaction.cpp +@@ -206,9 +206,6 @@ + } + + if (operations & DocumentTime) { +- Q_ASSERT(doc.m_mTime); +- Q_ASSERT(doc.m_cTime); +- + DocumentTimeDB::TimeInfo info; + info.mTime = doc.m_mTime; + info.cTime = doc.m_cTime; + |