File 07438391-kderuntime-nepomuk-47branch-reindexing.diff of Package kdebase4-runtime

commit 074383916dfdfb2cd5cf2b5dd269715229465366
Author: Sebastian Trueg <trueg@kde.org>
Date:   Mon Oct 24 20:48:07 2011 +0200

    Always re-index files on close after write events.
    
    This is required since mmapped files do not create modification events
    while being written.

diff --git a/nepomuk/services/filewatch/nepomukfilewatch.cpp b/nepomuk/services/filewatch/nepomukfilewatch.cpp
index 41d7de7..1ec2db3 100644
--- a/nepomuk/services/filewatch/nepomukfilewatch.cpp
+++ b/nepomuk/services/filewatch/nepomukfilewatch.cpp
@@ -97,13 +97,9 @@ namespace {
 
         //Only watch the strigi index folders for file creation and change.
         if( Nepomuk::StrigiServiceConfig::self()->shouldFolderBeIndexed( path ) ) {
-            modes |= KInotify::EventCreate;
-            modes |= KInotify::EventModify;
             modes |= KInotify::EventCloseWrite;
         }
         else {
-            modes &= (~KInotify::EventCreate);
-            modes &= (~KInotify::EventModify);
             modes &= (~KInotify::EventCloseWrite);
         }
 
@@ -150,10 +146,6 @@ Nepomuk::FileWatch::FileWatch( QObject* parent, const QList<QVariant>& )
              this, SLOT( slotFileMoved( QString, QString ) ) );
     connect( m_dirWatch, SIGNAL( deleted( QString, bool ) ),
              this, SLOT( slotFileDeleted( QString, bool ) ) );
-    connect( m_dirWatch, SIGNAL( created( QString ) ),
-             this, SLOT( slotFileCreated( QString ) ) );
-    connect( m_dirWatch, SIGNAL( modified( QString ) ),
-             this, SLOT( slotFileModified( QString ) ) );
     connect( m_dirWatch, SIGNAL( closedWrite( QString ) ),
              this, SLOT( slotFileClosedAfterWrite( QString ) ) );
     connect( m_dirWatch, SIGNAL( watchUserLimitReached() ),
@@ -200,7 +192,7 @@ void Nepomuk::FileWatch::watchFolder( const QString& path )
 #ifdef BUILD_KINOTIFY
     if ( m_dirWatch && !m_dirWatch->watchingPath( path ) )
         m_dirWatch->addWatch( path,
-                              KInotify::WatchEvents( KInotify::EventMove|KInotify::EventDelete|KInotify::EventDeleteSelf|KInotify::EventCreate|KInotify::EventModify|KInotify::EventCloseWrite ),
+                              KInotify::WatchEvents( KInotify::EventMove|KInotify::EventDelete|KInotify::EventDeleteSelf|KInotify::EventCloseWrite ),
                               KInotify::WatchFlags() );
 #endif
 }
@@ -243,32 +235,11 @@ void Nepomuk::FileWatch::slotFileDeleted( const QString& urlString, bool isDir )
 }
 
 
-void Nepomuk::FileWatch::slotFileCreated( const QString& path )
-{
-    if( StrigiServiceConfig::self()->shouldBeIndexed(path) ) {
-        // we only cache the file and wait until it has been closed, ie. the writing has been finished
-        m_modifiedFilesCache.insert(path);
-    }
-}
-
-
-void Nepomuk::FileWatch::slotFileModified( const QString& path )
-{
-    if( StrigiServiceConfig::self()->shouldBeIndexed(path) ) {
-        // we only cache the file and wait until it has been closed, ie. the writing has been finished
-        m_modifiedFilesCache.insert(path);
-    }
-}
-
-
 void Nepomuk::FileWatch::slotFileClosedAfterWrite( const QString& path )
 {
-    // we only need to update the file if it has actually been modified
-    QSet<KUrl>::iterator it = m_modifiedFilesCache.find(path);
-    if(it != m_modifiedFilesCache.end()) {
+    if(StrigiServiceConfig::self()->shouldBeIndexed(path)) {
         // we do not tell the file indexer right away but wait a short while in case the file is modified very often (irc logs for example)
         m_fileModificationQueue->enqueueUrl( path );
-        m_modifiedFilesCache.erase(it);
     }
 }
 
diff --git a/nepomuk/services/filewatch/nepomukfilewatch.h b/nepomuk/services/filewatch/nepomukfilewatch.h
index 7f0f8fb..efd8254 100644
--- a/nepomuk/services/filewatch/nepomukfilewatch.h
+++ b/nepomuk/services/filewatch/nepomukfilewatch.h
@@ -72,8 +72,6 @@ namespace Nepomuk {
         void slotFileMoved( const QString& from, const QString& to );
         void slotFileDeleted( const QString& urlString, bool isDir );
         void slotFilesDeleted( const QStringList& path );
-        void slotFileCreated( const QString& );
-        void slotFileModified( const QString& );
         void slotFileClosedAfterWrite( const QString& );
         void slotMovedWithoutData( const QString& );
         void connectToKDirWatch();
@@ -119,9 +117,6 @@ namespace Nepomuk {
         RegExpCache* m_pathExcludeRegExpCache;
         RemovableMediaCache* m_removableMediaCache;
 
-        /// stores all the file URLs that have been modified but not closed yet
-        QSet<KUrl> m_modifiedFilesCache;
-
         /// queue used to "compress" constant file modifications like downloads
         ActiveFileQueue* m_fileModificationQueue;
     };
openSUSE Build Service is sponsored by