[baloo] /: Disable compiling the Baloo Daemon without inotify

Vishesh Handa me at vhanda.in
Tue May 19 11:43:34 UTC 2015


Git commit 49fecea8e218ce03b01073c1604cfc0b683b1cc5 by Vishesh Handa.
Committed on 18/05/2015 at 14:33.
Pushed by vhanda into branch 'master'.

Disable compiling the Baloo Daemon without inotify

Baloo requires inotify. It's a hard dependency for us. When we do not
have it, we connect to kio signals. But that code path isn't tested
and only provides a sub-set of the required features. Baloo might be
somewhat usable on those systems, but we really do not know. The idea of
shipping a half baked product does not seem appealing. It seems better
to focus on what we can do, and do that well.

Baloo will still compile its library on non-Linux based systems, since
its a dependency for some applications (eg - Dolphin), but it will not do
anything.

CCMAIL: release-team at kde.org

M  +10   -2    CMakeLists.txt
M  +0    -8    autotests/unit/file/CMakeLists.txt
M  +8    -5    src/CMakeLists.txt
M  +1    -11   src/file/CMakeLists.txt
M  +7    -35   src/file/filewatch.cpp
M  +0    -5    src/file/filewatch.h
M  +2    -8    tests/file/CMakeLists.txt

http://commits.kde.org/baloo/49fecea8e218ce03b01073c1604cfc0b683b1cc5

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 95bc568..42ef1be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,11 @@ set_package_properties(LMDB PROPERTIES
 # Compiler flags
 add_definitions(-DQT_NO_KEYWORDS)
 
+set(BUILD_KINOTIFY False)
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+    set(BUILD_KINOTIFY True)
+endif()
+
 include_directories(
   ${LMDB_INCLUDE_DIR}
   ${CMAKE_SOURCE_DIR}
@@ -57,8 +62,11 @@ include_directories(
 # Targets
 add_subdirectory(src)
 add_subdirectory(icons)
-add_subdirectory(tests)
-add_subdirectory(autotests)
+
+if (${BUILD_KINOTIFY})
+    add_subdirectory(tests)
+    add_subdirectory(autotests)
+endif()
 
 # Config files
 set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5Baloo")
diff --git a/autotests/unit/file/CMakeLists.txt b/autotests/unit/file/CMakeLists.txt
index 08fffbe..fc0c70c 100644
--- a/autotests/unit/file/CMakeLists.txt
+++ b/autotests/unit/file/CMakeLists.txt
@@ -25,20 +25,12 @@ baloo_file_auto_tests(
 #
 # File Watch
 #
-set(BUILD_KINOTIFY False)
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-    set(BUILD_KINOTIFY True)
-    add_definitions(-DBUILD_KINOTIFY)
-endif()
-
 set(fileWatch_SRC filewatchtest.cpp ../lib/xattrdetector.cpp)
 ecm_add_test(${fileWatch_SRC}
     TEST_NAME "filewatchtest"
     LINK_LIBRARIES Qt5::Test Qt5::DBus KF5::Baloo baloofilecommon
 )
 
-
-
 #
 # Basic Indexing Queue Test
 #
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 207fc00..bd646e9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,10 @@
-add_subdirectory(codecs)
-add_subdirectory(engine)
 add_subdirectory(lib)
-add_subdirectory(file)
-add_subdirectory(kioslaves)
-add_subdirectory(tools)
+add_subdirectory(engine)
+add_subdirectory(codecs)
 add_subdirectory(qml)
+
+if (${BUILD_KINOTIFY})
+    add_subdirectory(file)
+    add_subdirectory(kioslaves)
+    add_subdirectory(tools)
+endif()
diff --git a/src/file/CMakeLists.txt b/src/file/CMakeLists.txt
index 3188794..8158b7f 100644
--- a/src/file/CMakeLists.txt
+++ b/src/file/CMakeLists.txt
@@ -27,19 +27,9 @@ set(file_static_lib_SRCS
     pendingfilequeue.cpp
     metadatamover.cpp
     pendingfile.cpp
+    kinotify.cpp
 )
 
-set(BUILD_KINOTIFY False)
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-    set(BUILD_KINOTIFY True)
-    set(file_static_lib_SRCS
-        ${file_static_lib_SRCS}
-        kinotify.cpp
-    )
-    add_definitions(-DBUILD_KINOTIFY)
-endif()
-
-
 add_library(baloofilecommon STATIC ${file_static_lib_SRCS})
 target_link_libraries(baloofilecommon
     Qt5::DBus
diff --git a/src/file/filewatch.cpp b/src/file/filewatch.cpp
index f319c9a..4c5c77f 100644
--- a/src/file/filewatch.cpp
+++ b/src/file/filewatch.cpp
@@ -26,15 +26,14 @@
 #include "pendingfile.h"
 #include "baloodebug.h"
 
-#ifdef BUILD_KINOTIFY
 #include "kinotify.h"
-#endif
 
-#include <QtCore/QDir>
-#include <QtCore/QThread>
-#include <QtDBus/QDBusConnection>
+#include <QDir>
+#include <QDateTime>
+#include <QDBusConnection>
 
-#include <KConfigGroup>
+#include <syslog.h>
+#include <kauth.h>
 
 using namespace Baloo;
 
@@ -42,9 +41,7 @@ FileWatch::FileWatch(Database* db, FileIndexerConfig* config, QObject* parent)
     : QObject(parent)
     , m_db(db)
     , m_config(config)
-#ifdef BUILD_KINOTIFY
     , m_dirWatch(0)
-#endif
 {
     Q_ASSERT(db);
     Q_ASSERT(config);
@@ -57,7 +54,6 @@ FileWatch::FileWatch(Database* db, FileIndexerConfig* config, QObject* parent)
     connect(m_pendingFileQueue, &PendingFileQueue::indexXAttr, this, &FileWatch::indexXAttr);
     connect(m_pendingFileQueue, &PendingFileQueue::removeFileIndex, m_metadataMover, &MetadataMover::removeFileMetadata);
 
-#ifdef BUILD_KINOTIFY
     // monitor the file system for changes (restricted by the inotify limit)
     m_dirWatch = new KInotify(m_config, this);
 
@@ -75,9 +71,6 @@ FileWatch::FileWatch(Database* db, FileIndexerConfig* config, QObject* parent)
     Q_FOREACH (const QString& folder, folders) {
         watchFolder(folder);
     }
-#else
-    connectToKDirNotify();
-#endif
 
     connect(m_config, &Baloo::FileIndexerConfig::configChanged, this, &FileWatch::updateIndexedFoldersWatches);
 }
@@ -92,7 +85,6 @@ FileWatch::~FileWatch()
 void FileWatch::watchFolder(const QString& path)
 {
     qCDebug(BALOO) << path;
-#ifdef BUILD_KINOTIFY
     if (m_dirWatch && !m_dirWatch->watchingPath(path)) {
         KInotify::WatchEvents flags(KInotify::EventMove | KInotify::EventDelete | KInotify::EventDeleteSelf
                                     | KInotify::EventCloseWrite | KInotify::EventCreate
@@ -100,7 +92,6 @@ void FileWatch::watchFolder(const QString& path)
 
         m_dirWatch->addWatch(path, flags, KInotify::WatchFlags());
     }
-#endif
 }
 
 void FileWatch::slotFileMoved(const QString& urlFrom, const QString& urlTo)
@@ -172,21 +163,6 @@ void FileWatch::slotAttributeChanged(const QString& path)
     m_pendingFileQueue->enqueue(file);
 }
 
-void FileWatch::connectToKDirNotify()
-{
-    // monitor KIO for changes
-    QDBusConnection::sessionBus().connect(QString(), QString(), QLatin1String("org.kde.KDirNotify"), QLatin1String("FileMoved"),
-                                          this, SIGNAL(slotFileMoved(QString,QString)));
-    QDBusConnection::sessionBus().connect(QString(), QString(), QLatin1String("org.kde.KDirNotify"), QLatin1String("FilesRemoved"),
-                                          this, SIGNAL(slotFilesDeleted(QStringList)));
-}
-
-
-#ifdef BUILD_KINOTIFY
-
-#include <syslog.h>
-#include <kauth.h>
-
 // Try to raise the inotify watch limit by executing
 // a helper which modifies /proc/sys/fs/inotify/max_user_watches
 bool raiseWatchLimit()
@@ -212,21 +188,18 @@ void FileWatch::slotInotifyWatchUserLimitReached(const QString& path)
         // so put something in the syslog so someone notices.
         syslog(LOG_USER | LOG_WARNING, "KDE Baloo File Indexer has reached the inotify folder watch limit. File changes may be ignored.");
         // we do it the brutal way for now hoping with new kernels and defaults this will never happen
-        // Delete the KInotify and switch to KDirNotify dbus signals
+        // Delete the KInotify
+        // FIXME: Maybe we should be aborting?
         if (m_dirWatch) {
             m_dirWatch->deleteLater();
             m_dirWatch = 0;
         }
-        connectToKDirNotify();
         Q_EMIT installedWatches();
     }
 }
-#endif
-
 
 void FileWatch::updateIndexedFoldersWatches()
 {
-#ifdef BUILD_KINOTIFY
     if (m_dirWatch) {
         QStringList folders = m_config->includeFolders();
         Q_FOREACH (const QString& folder, folders) {
@@ -234,6 +207,5 @@ void FileWatch::updateIndexedFoldersWatches()
             watchFolder(folder);
         }
     }
-#endif
 }
 
diff --git a/src/file/filewatch.h b/src/file/filewatch.h
index 4abe006..40bb438 100644
--- a/src/file/filewatch.h
+++ b/src/file/filewatch.h
@@ -53,10 +53,7 @@ private Q_SLOTS:
     void slotFileClosedAfterWrite(const QString&);
     void slotAttributeChanged(const QString& path);
     void slotFileModified(const QString& path);
-    void connectToKDirNotify();
-#ifdef BUILD_KINOTIFY
     void slotInotifyWatchUserLimitReached(const QString&);
-#endif
 
     /**
      * To be called whenever the list of indexed folders changes. This is done because
@@ -74,9 +71,7 @@ private:
     MetadataMover* m_metadataMover;
     FileIndexerConfig* m_config;
 
-#ifdef BUILD_KINOTIFY
     KInotify* m_dirWatch;
-#endif
 
     /// queue used to "compress" multiple file events like downloads
     PendingFileQueue* m_pendingFileQueue;
diff --git a/tests/file/CMakeLists.txt b/tests/file/CMakeLists.txt
index 93ce6c3..3b8c77f 100644
--- a/tests/file/CMakeLists.txt
+++ b/tests/file/CMakeLists.txt
@@ -31,14 +31,8 @@ target_link_libraries(basicindexingqueuetest-manual
 #  baloofilecommon
 #)
 
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-    if(BUILD_KINOTIFY)
-      add_executable(inotifytest inotify.cpp)
-      target_link_libraries(inotifytest
-        Qt5::Core baloofilecommon
-      )
-    endif()
-endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
+add_executable(inotifytest inotify.cpp)
+target_link_libraries(inotifytest Qt5::Core baloofilecommon)
 
 #
 # Storage Devices



More information about the release-team mailing list