*This patch doesn't work perfectly.*
I seem to to be duplicating code from StrigiServiceConfig, which is not
something I'm too happy about.
The moment some watched folder is moved/renamed, metadata mover fires up,
and starts moving the metadata. Meanwhile the strigi config file is updated
and the strigi service detects that the file has been changed (exact same
code as in the testpatch) and then proceeds to delete unnecessary metadata
via removeOldAndUnwantedEntries(). Which removes some of the indexed data.
And since some of the metadata has been removed the filewatch service can't
move it. After that the strigi service proceeds to index the moved files
who's metadata isn't intact.
:-/
It's doing what we want, but not how we want it. We need to delay writing to
the config file until the metadata mover has finished is job. I could just
slap on a signal which is fired when it changes from a Busy to Idle state
(and that'll work) but for all you know the user could be performing other
tasks and the metadata mover doesn't become idle for a long time. (Maybe
he's monitoring a network drive where other users are doing stuff).
This method will ultimately result in what we want except when then this
happens -
1. The user moves some folder which is being indexed.
2. The metadata mover is active.
3. He edits the files being watched via kcm.
4. The metadata mover becomes idle.
There is one more issue. Say I have an indexed folder *Boo*, and it has a
sub-folder *Yoda*. Yoda is moved somewhere outside Boo which isn't being
indexed. Should Yoda still be indexed? Or Not? I think it should be. What do
you think?
Index: nepomukfilewatch.cpp
===================================================================
--- nepomukfilewatch.cpp (revision 1119639)
+++ nepomukfilewatch.cpp (working copy)
@@ -31,7 +31,9 @@
#include <KDebug>
#include <KUrl>
#include <KPluginFactory>
-
+#include <KDirWatch>
+#include <KStandardDirs>
+#include <KConfigGroup>
using namespace Soprano;
@@ -78,6 +80,19 @@ Nepomuk::FileWatch::FileWatch( QObject*
#else
connectToKDirWatch();
#endif
+
+ //Tracking Strigi indexed folder list
+
+ KDirWatch* dirWatch = KDirWatch::self();
+ connect( dirWatch, SIGNAL( dirty( const QString& ) ),
+ this, SLOT( slotStrigiConfigChanged() ) );
+ connect( dirWatch, SIGNAL( created( const QString& ) ),
+ this, SLOT( slotStrigiConfigChanged() ) );
+
+ KConfig config("nepomukstrigirc");
+ dirWatch->addFile( KStandardDirs::locateLocal( "config", config.name() ) );
+
+ slotStrigiConfigChanged();
}
@@ -108,6 +123,23 @@ void Nepomuk::FileWatch::slotFileMoved(
kDebug() << from << to;
m_metadataMover->moveFileMetadata( from, to );
+
+ //Handling Strigi indexed folder list
+ if( !m_strigiFoldersHash.contains( urlFrom ) )
+ return;
+
+ //TODO: Optimize
+ KConfig config("nepomukstrigirc");
+
+ QStringList includeFolders = config.group( "General" ).readPathEntry( "folders", QStringList());
+ includeFolders.replaceInStrings( urlFrom, urlTo );
+
+ QStringList excludeFolders = config.group( "General" ).readPathEntry( "exclude folders", QStringList());
+ excludeFolders.replaceInStrings( urlFrom, urlTo );
+
+ config.group( "General" ).writePathEntry( "folders", includeFolders );
+ config.group( "General" ).writePathEntry( "exclude folders", excludeFolders );
+ kDebug() << "Done!!";
}
@@ -159,4 +191,25 @@ void Nepomuk::FileWatch::slotInotifyWatc
}
#endif
+
+void Nepomuk::FileWatch::slotStrigiConfigChanged()
+{
+ kDebug();
+
+ m_strigiFoldersHash.clear();
+ KConfig config("nepomukstrigirc");
+
+ QStringList include = config.group( "General" ).readPathEntry( "folders", QStringList());
+ foreach( QString path, include ) {
+ kDebug() << "Adding : " << path;
+ m_strigiFoldersHash.insert( path, true );
+ }
+
+ QStringList exclude = config.group( "General" ).readPathEntry( "exclude folders", QStringList());
+ foreach( QString path, exclude ) {
+ kDebug() << "Adding : " << path;
+ m_strigiFoldersHash.insert( path, false );
+ }
+}
+
#include "nepomukfilewatch.moc"
Index: nepomukfilewatch.h
===================================================================
--- nepomukfilewatch.h (revision 1119639)
+++ nepomukfilewatch.h (working copy)
@@ -23,6 +23,7 @@
#include <QtCore/QUrl>
#include <QtCore/QVariant>
+#include <QtCore/QHash>
namespace Soprano {
class Model;
@@ -60,9 +61,11 @@ namespace Nepomuk {
#ifdef BUILD_KINOTIFY
void slotInotifyWatchUserLimitReached();
#endif
+ void slotStrigiConfigChanged();
private:
MetadataMover* m_metadataMover;
+ QHash<QString, bool> m_strigiFoldersHash;
#ifdef BUILD_KINOTIFY
KInotify* m_dirWatch;
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk