If you rename a folder with loads of data (it should have metadata), the
MetadataMover::updateMetadata function would sometimes skip a resource or
two. This doesn't always happen. Just occasionally. Look at the output -
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: r -> * QUrl(
"nepomuk:/res/0887efd7-b6ab-4acf-8f0a-74ed7106c6ed" )*
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: url -> *
KUrl("file:///home/vishesh/Index_LOO/Phonemusic/19.mp3")*
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata:
KUrl("file:///home/vishesh/Index_LOO/Phonemusic/19.mp3") ->
KUrl("file:///home/vishesh/Index_L/Phonemusic/19.mp3")
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: Old Resource Exists
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: r -> *QUrl(
"nepomuk:/res/b9f11a5b-cbe3-4797-9fe0-0f293a215a9e" )*
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: url -> *
KUrl("file:///home/vishesh/Index_LOO/Phonemusic/19.mp3")*
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata:
KUrl("file:///home/vishesh/Index_LOO/Phonemusic/19.mp3") ->
KUrl("file:///home/vishesh/Index_L/Phonemusic/19.mp3")
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: Old Resource Exists
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: r -> QUrl(
"nepomuk:/res/38616b7c-9540-46de-aa5c-e12971cac64d" )
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: url ->
KUrl("file:///home/vishesh/Index_LOO/Phonemusic/22.mp3")
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata:
KUrl("file:///home/vishesh/Index_LOO/Phonemusic/22.mp3") ->
KUrl("file:///home/vishesh/Index_L/Phonemusic/22.mp3")
nepomukfilewatch(10425)/nepomuk (filewatch service)
Nepomuk::MetadataMover::updateMetadata: Old Resource Exists
In the second case. The resource
*nepomuk:/res/b9f11a5b-cbe3-4797-9fe0-0f293a215a9e
*actaully has a nie:url of *file:///home/vishesh/Index_L/Phonemusic/20.mp3*.
This was kinda difficult to track down, but the solution is fairly simple,
and was mentioned in the Soprano::QueryResultIterator documentation.
Many backends do lock the underlying Model during iteration. Thus,
it is always a good idea to cache the results if they are to be used
to modify the model to prevent a deadlock:
I really should read the documentation more thoroughly.
*
Other things :*
1. The kinotify currently tracks hidden files as well. Why is that? Tracking
hidden files means you track all kind of temporary files and are alerted
when they are altered. It makes debugging a million times harder. It's just
a matter of changing *KInotify::Private::watchHiddenFolders* to false. If
you don't agree with me, then can we please make it configurable?
2. Minor optimization on *MetadataMover::updateMetadata* -> Patch!
- Vishesh Handa
Index: services/filewatch/metadatamover.cpp
===================================================================
--- services/filewatch/metadatamover.cpp (revision 1125616)
+++ services/filewatch/metadatamover.cpp (working copy)
@@ -242,13 +242,15 @@ void Nepomuk::MetadataMover::updateMetad
from.url(KUrl::AddTrailingSlash) );
kDebug() << query;
Soprano::QueryResultIterator it = m_model->executeQuery( query, Soprano::Query::QueryLanguageSparql );
- while ( it.next() ) {
+ QList<Soprano::BindingSet> allBindings = it.allBindings();
+
+ foreach( const Soprano::BindingSet & bs, allBindings) {
// the resource URI of the resource to update
- const QUrl uri = it[0].uri();
+ const QUrl uri = bs["r"].uri();
// the old URL of the resource to update
- const KUrl url = it[1].uri();
+ const KUrl url = bs["url"].uri();
// now construct the new URL
const QString oldBasePath = from.path( KUrl::AddTrailingSlash );
Index: metadatamover.cpp
===================================================================
--- metadatamover.cpp (revision 1125616)
+++ metadatamover.cpp (working copy)
@@ -242,6 +242,10 @@ void Nepomuk::MetadataMover::updateMetad
from.url(KUrl::AddTrailingSlash) );
kDebug() << query;
Soprano::QueryResultIterator it = m_model->executeQuery( query, Soprano::Query::QueryLanguageS
parql );
+
+ const QString oldBasePath = from.path( KUrl::AddTrailingSlash );
+ const QString newBasePath = to.path( KUrl::AddTrailingSlash );
+
while ( it.next() ) {
// the resource URI of the resource to update
@@ -251,8 +255,6 @@ void Nepomuk::MetadataMover::updateMetad
const KUrl url = it[1].uri();
// now construct the new URL
- const QString oldBasePath = from.path( KUrl::AddTrailingSlash );
- const QString newBasePath = to.path( KUrl::AddTrailingSlash );
QString oldRelativePath = url.path().mid( oldBasePath.length() );
KUrl newUrl( newBasePath + oldRelativePath );
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk