Hi
Currently the initial indexing timing is buggy. The timer isn't paused when
the indexing is paused. This patch fixes the issue.
I've done a minor amount of refactoring by adding two private slots -
pauseIndexing and resumeIndexing. Should I have prefixed them with slot?
I've refactored the code cause it makes it easier to read, and the TODO
given (Add actions to the initial indexing notification) is now easily
doable.
Now to the part I suck at - Testing. How in the world am I supposed to test
it? It tried to change the location of the virtuoso repository
(nepomukserverrc file) to a pen drive which didn't have adequate space, but
that didn't really work. I started getting errors like -
[/home/vishesh/kde/bin/nepomukservicestub]
"/home/vishesh/kde/bin/nepomukservicestub(5372)" Error in thread 3052354416
: "SQLExecDirect failed on query 'sparql ask where { {
<nepomuk:/ctx/7d689871-f944-460b-b0bf-75dbd444766c> ?p1 ?o1 . } UNION { ?s2
<nepomuk:/ctx/7d689871-f944-460b-b0bf-75dbd444766c> ?o2 . } UNION { ?s3 ?p3
<nepomuk:/ctx/7d689871-f944-460b-b0bf-75dbd444766c> . } UNION { graph
<nepomuk:/ctx/7d689871-f944-460b-b0bf-75dbd444766c> { ?s4 ?4 ?o4 . } . } }'
(iODBC Error: [OpenLink][Virtuoso iODBC Driver][Virtuoso Server]SR174: Log
out of disk : while writing new IRI_ID allocation to log file)"
And I didn't get any notification saying there wasn't adequate space. :-/
Could somebody test it out by draining their laptop battery? I have no idea
how I can emulate a battery on my desktop.
Thanks
- Vishesh Handa
Index: eventmonitor.h
===================================================================
--- eventmonitor.h (revision 1116179)
+++ eventmonitor.h (working copy)
@@ -42,6 +42,8 @@
void slotPowerManagementStatusChanged( bool conserveResources );
void slotCheckAvailableSpace();
void slotIndexingStopped();
+ void pauseIndexing(int pauseState);
+ void resumeIndexing();
private:
enum {
@@ -57,6 +59,7 @@
QTimer m_availSpaceTimer;
QTime m_initialIndexTime;
+ QTime m_pausedIndexTime; //records the amount of time m_initialIndexTime is paused.
};
}
Index: eventmonitor.cpp
===================================================================
--- eventmonitor.cpp (revision 1116179)
+++ eventmonitor.cpp (working copy)
@@ -85,16 +85,14 @@
{
if ( !conserveResources && m_pauseState == PausedDueToPowerManagement ) {
kDebug() << "Resuming indexer due to power management";
- m_pauseState = NotPaused;
- m_indexScheduler->resume();
+ resumeIndexing();
sendEvent( "indexingResumed", i18n("Resuming indexing of files for fast searching."), "battery-charging" );
}
else if ( conserveResources &&
m_indexScheduler->isRunning() &&
!m_indexScheduler->isSuspended() ) {
kDebug() << "Pausing indexer due to power management";
- m_pauseState = PausedDueToPowerManagement;
- m_indexScheduler->suspend();
+ pauseIndexing( PausedDueToPowerManagement );
sendEvent( "indexingSuspended", i18n("Suspending the indexing of files to preserve resources."), "battery-100" );
}
}
@@ -107,8 +105,7 @@
if ( info.available() <= StrigiServiceConfig::self()->minDiskSpace() ) {
if ( m_indexScheduler->isRunning() &&
!m_indexScheduler->isSuspended() ) {
- m_pauseState = PausedDueToAvailSpace;
- m_indexScheduler->suspend();
+ pauseIndexing( PausedDueToAvailSpace );
sendEvent( "indexingSuspended",
i18n("Disk space is running low (%1 left). Suspending indexing of files.",
KIO::convertSize( info.available() ) ),
@@ -117,8 +114,7 @@
}
else if ( m_pauseState == PausedDueToAvailSpace ) {
kDebug() << "Resuming indexer due to disk space";
- m_pauseState = NotPaused;
- m_indexScheduler->resume();
+ resumeIndexing();
sendEvent( "indexingResumed", i18n("Resuming indexing of files for fast searching."), "drive-harddisk" );
}
}
@@ -143,4 +139,22 @@
}
}
+
+void Nepomuk::EventMonitor::pauseIndexing(int pauseState)
+{
+ m_pauseState = pauseState;
+ m_indexScheduler->suspend();
+ m_pausedIndexTime.restart();
+}
+
+
+void Nepomuk::EventMonitor::resumeIndexing()
+{
+ m_pauseState = NotPaused;
+ m_indexScheduler->resume();
+
+ const int elapsed = m_pausedIndexTime.elapsed();
+ m_initialIndexTime.addMSecs( -elapsed );
+}
+
#include "eventmonitor.moc"
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk