Commit 6e6e676b authored by Simeon Bird's avatar Simeon Bird
Browse files

FileIndexer: Check for nepomukindexer crashing.

It is not enough to check that the indexer returns 0.
We must also check that it did not crash, and, if it did,
return an error.

This patch also defines an error enum for FileIndexingJob.

BUG: 324307
REVIEW: 112475
parent d14700f5
......@@ -69,7 +69,7 @@ void Nepomuk2::FileIndexingJob::start()
m_process->setProgram( exe, args );
m_process->setOutputChannelMode(KProcess::OnlyStdoutChannel);
connect( m_process, SIGNAL(finished(int)), this, SLOT(slotIndexedFile(int)) );
connect( m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIndexedFile(int, QProcess::ExitStatus)) );
m_process->start();
// start the timer which will kill the process if it does not terminate after 5 minutes
......@@ -94,15 +94,19 @@ void Nepomuk2::FileIndexingJob::slotProcessNonExistingFile()
}
void Nepomuk2::FileIndexingJob::slotIndexedFile(int exitCode)
void Nepomuk2::FileIndexingJob::slotIndexedFile(int exitCode, QProcess::ExitStatus exitStatus)
{
// stop the timer since there is no need to kill the process anymore
m_processTimer->stop();
//kDebug() << "Indexing of " << m_url.toLocalFile() << "finished with exit code" << exitCode;
if(exitStatus != QProcess::NormalExit) {
setError( IndexerCrashed );
setErrorText( QLatin1String( "Indexer process crashed on " ) + m_url.toLocalFile() );
}
if(exitCode == 1) {
setError( KJob::UserDefinedError );
setErrorText( QLatin1String( "Indexer process returned with an error for" ) + m_url.toLocalFile() );
setError( IndexerFailed );
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)) {
......
......@@ -24,8 +24,8 @@
#include <KJob>
#include <KUrl>
#include <KProcess>
class KProcess;
class QFileInfo;
class QTimer;
......@@ -59,6 +59,15 @@ namespace Nepomuk2 {
virtual void start();
/**
* Error codes: IndexerFailed is emitted when the indexer returns 1
* IndexerCrashed is emitted when the indexer crashed
*/
enum {
IndexerFailed = UserDefinedError,
IndexerCrashed
};
Q_SIGNALS:
/**
* Emitted once the indexing for a file or resource has finished.
......@@ -73,7 +82,7 @@ namespace Nepomuk2 {
// TODO: actually emit the indexingDone signal
private slots:
void slotIndexedFile(int exitCode);
void slotIndexedFile(int exitCode, QProcess::ExitStatus exitStatus);
void slotProcessTimerTimeout();
void slotProcessNonExistingFile();
......
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