Commit d14700f5 authored by Simeon Bird's avatar Simeon Bird
Browse files

FileIndexer: Really do not index file multiple times

In commit c4411982
I attempted to implement not re-indexing files which failed to index.

However, my code made no sense!

It attempted to set kext::indexingLevel to -1 if the nepomukindexer job
returned with an error. But, the KJob never set an error even if the
indexer returned 1, so nothing happened.

Even when this was fixed, it still didn't work, because I was updating
the indexingLevel of the current filename, not the resource URI of the
current filename.

So, to summarise, I was silly. This one works, and an easy way to test
it is to replace /usr/bin/nepomukindexer with:

 #!/bin/bash
 exit 1

BUG: 324307
parent 9a4dcb1b
......@@ -100,11 +100,15 @@ void Nepomuk2::FileIndexingJob::slotIndexedFile(int exitCode)
m_processTimer->stop();
//kDebug() << "Indexing of " << m_url.toLocalFile() << "finished with exit code" << exitCode;
if(exitCode == 1 && FileIndexerConfig::self()->isDebugModeEnabled()) {
QFile errorLogFile(KStandardDirs::locateLocal("data", QLatin1String("nepomuk/file-indexer-error-log"), true));
if(errorLogFile.open(QIODevice::Append)) {
QTextStream s(&errorLogFile);
s << m_url.toLocalFile() << ": " << QString::fromLocal8Bit(m_process->readAllStandardOutput()) << endl;
if(exitCode == 1) {
setError( KJob::UserDefinedError );
setErrorText( QLatin1String( "Indexer process returned with an error for" ) + m_url.toLocalFile() );
if(FileIndexerConfig::self()->isDebugModeEnabled()) {
QFile errorLogFile(KStandardDirs::locateLocal("data", QLatin1String("nepomuk/file-indexer-error-log"), true));
if(errorLogFile.open(QIODevice::Append)) {
QTextStream s(&errorLogFile);
s << m_url.toLocalFile() << ": " << QString::fromLocal8Bit(m_process->readAllStandardOutput()) << endl;
}
}
}
emitResult();
......@@ -112,10 +116,11 @@ void Nepomuk2::FileIndexingJob::slotIndexedFile(int exitCode)
void Nepomuk2::FileIndexingJob::slotProcessTimerTimeout()
{
kDebug() << "Killing the indexer process which seems stuck for" << m_url;
m_process->disconnect(this);
m_process->kill();
m_process->waitForFinished();
setError( KJob::KilledJobError );
setErrorText( QLatin1String("Indexer process got stuck for") + m_url.toLocalFile() );
emitResult();
}
......
......@@ -97,9 +97,17 @@ void FileIndexingQueue::slotFinishedIndexingFile(KJob* job)
{
if( job->error() ) {
kDebug() << job->errorString();
// Update the indexing level to -1, signalling an error,
// so the next round of the queue doesn't try to index it again.
updateIndexingLevel(m_currentUrl, -1);
// Get the uri of the current file
QString query = QString::fromLatin1("select ?r where { ?r nie:url %1 . }")
.arg( Soprano::Node::resourceToN3( m_currentUrl ) );
Soprano::Model* model = ResourceManager::instance()->mainModel();
Soprano::QueryResultIterator it = model->executeQuery( query, Soprano::Query::QueryLanguageSparqlNoInference );
if( it.next() ) {
// Update the indexing level to -1, signalling an error,
// so the next round of the queue doesn't try to index it again.
updateIndexingLevel(it[0].uri(), -1);
}
}
QUrl url = m_currentUrl;
......
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