summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishesh Handa <me@vhanda.in>2012-08-28 17:52:57 (GMT)
committerVishesh Handa <me@vhanda.in>2012-08-29 12:35:53 (GMT)
commit150a55d5eaabd8ad9a97112214fc2e008e9a1d11 (patch)
tree8c38d6cc150944b6c4f31dbd4ccc2c69a86ae773
parent805a532ec2d70758977960d9281d2f77f31dab7f (diff)
FileIndexer: Do not check for new files on startup
Only check for changes if the strigi version changes, cause in that case their may be a new plugin or an earlier plugin may have been fixed. REVIEW: 106256
-rw-r--r--services/fileindexer/CMakeLists.txt24
-rw-r--r--services/fileindexer/fileindexer.cpp22
-rw-r--r--services/fileindexer/fileindexerconfig.cpp11
-rw-r--r--services/fileindexer/fileindexerconfig.h13
4 files changed, 66 insertions, 4 deletions
diff --git a/services/fileindexer/CMakeLists.txt b/services/fileindexer/CMakeLists.txt
index f9eea59..56580db 100644
--- a/services/fileindexer/CMakeLists.txt
+++ b/services/fileindexer/CMakeLists.txt
@@ -2,6 +2,18 @@ project(fileindexerservice)
include(SopranoAddOntology)
+# Check if strigiconfig.h has version functions
+include(CheckCXXSourceCompiles)
+set(CMAKE_REQUIRED_INCLUDES ${STRIGI_INCLUDE_DIR})
+set(CMAKE_REQUIRED_LIBRARIES ${STRIGI_STREAMS_LIBRARY})
+CHECK_CXX_SOURCE_COMPILES(
+ "#include <strigi/strigiconfig.h>\nint main(int ac, char** av) { Strigi::versionString(); }"
+ STRIGI_HAS_VERSION_HEADER
+)
+if(${STRIGI_HAS_VERSION_HEADER})
+ add_definitions(-DSTRIGI_HAS_VERSION_HEADER)
+endif(${STRIGI_HAS_VERSION_HEADER})
+
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=300106)
include_directories(
@@ -25,7 +37,7 @@ qt4_add_dbus_interface(nepomukfileindexer_SRCS ../../interfaces/org.kde.nepomuk.
kde4_add_plugin(nepomukfileindexer ${nepomukfileindexer_SRCS})
-target_link_libraries(nepomukfileindexer
+set(fileindexer_LIBS
nepomukcommon
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
@@ -33,7 +45,15 @@ target_link_libraries(nepomukfileindexer
${KDE4_KIDLETIME_LIBS}
nepomukcore
${SOPRANO_LIBRARIES}
- )
+)
+
+if(${STRIGI_HAS_VERSION_HEADER})
+ set(fileindexer_LIBS ${fileindexer_LIBS} ${STRIGI_STREAMS_LIBRARY} )
+endif(${STRIGI_HAS_VERSION_HEADER})
+
+target_link_libraries(nepomukfileindexer
+ ${fileindexer_LIBS}
+)
install(
FILES nepomukfileindexer.desktop
diff --git a/services/fileindexer/fileindexer.cpp b/services/fileindexer/fileindexer.cpp
index af8be4d..b6aacc7 100644
--- a/services/fileindexer/fileindexer.cpp
+++ b/services/fileindexer/fileindexer.cpp
@@ -34,6 +34,9 @@
#include <QtCore/QTimer>
+#ifdef STRIGI_HAS_VERSION_HEADER
+ #include <strigi/strigiconfig.h>
+#endif
Nepomuk2::FileIndexer::FileIndexer( QObject* parent, const QList<QVariant>& )
: Service( parent )
@@ -79,8 +82,16 @@ Nepomuk2::FileIndexer::FileIndexer( QObject* parent, const QList<QVariant>& )
m_indexScheduler->setIndexingSpeed( IndexScheduler::SnailPace );
// start initial indexing honoring the hidden config option to disable it
- if(FileIndexerConfig::self()->isInitialRun() ||
- !FileIndexerConfig::self()->initialUpdateDisabled()) {
+#ifdef STRIGI_HAS_VERSION_HEADER
+ const QString strigiVersion(Strigi::versionString());
+#else
+ const QString strigiVersion("unknown");
+#endif
+
+ if( ( FileIndexerConfig::self()->isInitialRun() ||
+ FileIndexerConfig::self()->strigiVersion() != strigiVersion )
+ && !FileIndexerConfig::self()->initialUpdateDisabled() )
+ {
m_indexScheduler->updateAll();
}
@@ -141,6 +152,13 @@ void Nepomuk2::FileIndexer::slotIdleTimerResume()
void Nepomuk2::FileIndexer::slotIndexingDone()
{
FileIndexerConfig::self()->setInitialRun(false);
+
+#ifdef STRIGI_HAS_VERSION_HEADER
+ const QString strigiVersion(Strigi::versionString());
+#else
+ const QString strigiVersion("unknown");
+#endif
+ FileIndexerConfig::self()->setStrigiVersion(strigiVersion);
}
diff --git a/services/fileindexer/fileindexerconfig.cpp b/services/fileindexer/fileindexerconfig.cpp
index 2ca973c..9100f8e 100644
--- a/services/fileindexer/fileindexerconfig.cpp
+++ b/services/fileindexer/fileindexerconfig.cpp
@@ -343,4 +343,15 @@ bool Nepomuk2::FileIndexerConfig::isDebugModeEnabled() const
return m_config.group( "General" ).readEntry( "debug mode", false );
}
+QString Nepomuk2::FileIndexerConfig::strigiVersion() const
+{
+ return m_config.group( "General" ).readEntry( "strigiVersion", QString() );
+}
+
+void Nepomuk2::FileIndexerConfig::setStrigiVersion(const QString& version)
+{
+ m_config.group( "General" ).writeEntry( "strigiVersion", version );
+}
+
+
#include "fileindexerconfig.moc"
diff --git a/services/fileindexer/fileindexerconfig.h b/services/fileindexer/fileindexerconfig.h
index 1113220..23f014a 100644
--- a/services/fileindexer/fileindexerconfig.h
+++ b/services/fileindexer/fileindexerconfig.h
@@ -151,6 +151,12 @@ namespace Nepomuk2 {
*/
bool isDebugModeEnabled() const;
+ /**
+ * Returns the libstreamanalyzer version which was last used when all
+ * the files were checked, and indexed
+ */
+ QString strigiVersion() const;
+
Q_SIGNALS:
void configChanged();
@@ -168,6 +174,13 @@ namespace Nepomuk2 {
*/
void setInitialRun(bool isInitialRun);
+ /**
+ * Should be called once all the files have been indexed. This is done in
+ * order to avoid rechecking all the files if the strigi version has not
+ * changed.
+ */
+ void setStrigiVersion(const QString& version);
+
private Q_SLOTS:
void slotConfigDirty();