This removes Resources which do not have a valid nie:uri. I've added it as a
separate function, but I could couple it with the *
IndexScheduler::removeOldAndUnwantedEntries()* if you want. I've used
Nepomuk::Resouce::remove to remove them. Should I have just directly deleted
the entire context/graph ?

Please let me know.

- Vishesh Handa
Index: services/strigi/indexscheduler.cpp
===================================================================
--- services/strigi/indexscheduler.cpp	(revision 1124561)
+++ services/strigi/indexscheduler.cpp	(working copy)
@@ -711,6 +711,32 @@ void Nepomuk::IndexScheduler::removeOldA
 
         ResourceManager::instance()->mainModel()->removeContext( it[0] );
     }
+    
+    removeInvlaidEntries();
+}
+
+
+void Nepomuk::IndexScheduler::removeInvlaidEntries()
+{
+    QString query = QString::fromLatin1( "select distinct ?r ?url ?g where { ?r %1 ?url. FILTER( regex(str(?url), 'file://') ).}" )
+                                       .arg( Soprano::Node::resourceToN3( Nepomuk::Vocabulary::NIE::url() ) );
+    Soprano::QueryResultIterator it = ResourceManager::instance()->mainModel()->executeQuery( query, Soprano::Query::QueryLanguageSparql );
+
+    while( it.next() ) {
+        QUrl url( it["url"].toString() );
+        QString file = url.toLocalFile();
+               
+        if( file.isEmpty() || QFile::exists(file) )
+            continue;
+        
+        kDebug() << "REMOVING " << file;
+        Resource res( url );
+        res.remove();
+        
+        if ( !waitForContinue() ) {
+            break;
+        }
+    }
 }
 
 
Index: services/strigi/indexscheduler.h
===================================================================
--- services/strigi/indexscheduler.h	(revision 1124561)
+++ services/strigi/indexscheduler.h	(working copy)
@@ -198,6 +198,7 @@ namespace Nepomuk {
          * to index anymore.
          */
         void removeOldAndUnwantedEntries();
+        void removeInvlaidEntries();
 
         bool m_suspended;
         bool m_stopped;
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk

Reply via email to