Commit 3d070535 authored by Simeon Bird's avatar Simeon Bird
Browse files

Remove m_recentlyFinishedRequests from the metadatamover.

The filewatch service calls moveFileMetadata ( oldPath, newPath).

This sticks the metadata move into a queue, like so:
if ( !m_updateQueue.contains( req ) &&
!m_recentlyFinishedRequests.contains( req ) )
m_updateQueue.enqueue( req );

If you move oldPath to newPath twice in fairly quick succession, the
first move will still be in the m_recentlyFinishedRequests, and the metadata move will
not be queued.

git blame tells me that trueg added this check with commit 840dbb60
in 2009, to prevent events received twice from being acted on twice.
However, it means that if an event is repeated quickly, the repeat
will not be acted on, even if it should.
(eg, move A -> B -> A -> B in quick succession)

Nowadays we just use inotifty, which, so far as I know,
cannot deliver the same event twice. and so
we can just remove the list entirely.

In other words: bug 286854 is due to a rogue, no longer needed, workaround.

BUG: 286854
FIXED-IN: 4.10
REVIEW: 107260
parent 0be47089
......@@ -44,12 +44,6 @@ Nepomuk2::MetadataMover::MetadataMover( Soprano::Model* model, QObject* parent )
this, SLOT(slotWorkUpdateQueue()),
Qt::DirectConnection);
// setup the cleanup timer which removes requests that are done
m_recentlyFinishedRequestsTimer = new QTimer(this);
connect( m_recentlyFinishedRequestsTimer, SIGNAL( timeout() ),
this, SLOT( slotClearRecentlyFinishedRequests() ),
Qt::DirectConnection );
m_recentlyFinishedRequestsTimer->setInterval( 30000 );
}
......@@ -67,8 +61,7 @@ void Nepomuk2::MetadataMover::moveFileMetadata( const KUrl& from, const KUrl& to
QMutexLocker lock(&m_queueMutex);
UpdateRequest req( from, to );
if ( !m_updateQueue.contains( req ) &&
!m_recentlyFinishedRequests.contains( req ) )
if ( !m_updateQueue.contains( req ) )
m_updateQueue.enqueue( req );
QTimer::singleShot(0, this, SLOT(slotStartUpdateTimer()));
......@@ -89,8 +82,7 @@ void Nepomuk2::MetadataMover::removeFileMetadata( const KUrl::List& files )
foreach( const KUrl& file, files ) {
UpdateRequest req( file );
if ( !m_updateQueue.contains( req ) &&
!m_recentlyFinishedRequests.contains( req ) )
if ( !m_updateQueue.contains( req ) )
m_updateQueue.enqueue( req );
}
......@@ -106,7 +98,6 @@ void Nepomuk2::MetadataMover::slotWorkUpdateQueue()
// work the queue
if( !m_updateQueue.isEmpty() ) {
UpdateRequest updateRequest = m_updateQueue.dequeue();
m_recentlyFinishedRequests.insert( updateRequest );
// unlock after queue utilization
lock.unlock();
......@@ -208,27 +199,6 @@ void Nepomuk2::MetadataMover::updateMetadata( const KUrl& from, const KUrl& to )
}
// removes all finished requests older than 1 minute
void Nepomuk2::MetadataMover::slotClearRecentlyFinishedRequests()
{
QMutexLocker lock( &m_queueMutex );
QSet<UpdateRequest>::iterator it = m_recentlyFinishedRequests.begin();
while ( it != m_recentlyFinishedRequests.end() ) {
const UpdateRequest& req = *it;
if ( req.timestamp().secsTo( QDateTime::currentDateTime() ) > 60 ) {
it = m_recentlyFinishedRequests.erase( it );
}
else {
++it;
}
}
if(m_recentlyFinishedRequests.isEmpty()) {
kDebug() << "No more old requests. Stopping timer.";
m_recentlyFinishedRequestsTimer->stop();
}
}
// start the timer in the update thread
void Nepomuk2::MetadataMover::slotStartUpdateTimer()
......@@ -236,9 +206,6 @@ void Nepomuk2::MetadataMover::slotStartUpdateTimer()
if(!m_queueTimer->isActive()) {
m_queueTimer->start();
}
if(!m_recentlyFinishedRequestsTimer->isActive()) {
m_recentlyFinishedRequestsTimer->start();
}
}
#include "metadatamover.moc"
......@@ -59,7 +59,6 @@ namespace Nepomuk2 {
void movedWithoutData( const QString& path );
private Q_SLOTS:
void slotClearRecentlyFinishedRequests();
void slotWorkUpdateQueue();
/**
......@@ -82,18 +81,9 @@ namespace Nepomuk2 {
// if the second url is empty, just delete the metadata
QQueue<UpdateRequest> m_updateQueue;
// we use several systems to watch for file operations.
// Thus, we can get the same request more than once. We then
// need a way to determine if we have already handled it.
// (otherwise we would remove the previously moved data.)
// The only way to do that is to keep a list of all requests
// that have been handled in the last N seconds.
QSet<UpdateRequest> m_recentlyFinishedRequests;
QMutex m_queueMutex;
QTimer* m_queueTimer;
QTimer* m_recentlyFinishedRequestsTimer;
Soprano::Model* m_model;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment