mirror of https://github.com/kiwix/libkiwix.git
+ fixed indexing progression > 100% (ID: 3539572)
This commit is contained in:
parent
28138e7ff9
commit
d1ccecc5f7
|
@ -67,22 +67,23 @@ namespace kiwix {
|
||||||
|
|
||||||
/* Goes trough all articles */
|
/* Goes trough all articles */
|
||||||
zim::File *zimHandler = reader.getZimFileHandler();
|
zim::File *zimHandler = reader.getZimFileHandler();
|
||||||
unsigned int currentOffset = zimHandler->getNamespaceBeginOffset('A');;
|
unsigned int currentOffset = zimHandler->getNamespaceBeginOffset('A');
|
||||||
unsigned int lastOffset = zimHandler->getNamespaceEndOffset('A');;
|
unsigned int lastOffset = zimHandler->getNamespaceEndOffset('A');
|
||||||
zim::Article currentArticle;
|
zim::Article currentArticle;
|
||||||
|
|
||||||
while (currentOffset <= lastOffset) {
|
while (currentOffset < lastOffset) {
|
||||||
/* Redirects are not indexed */
|
currentArticle = zimHandler->getArticle(currentOffset);
|
||||||
do {
|
|
||||||
currentArticle = zimHandler->getArticle(currentOffset++);
|
|
||||||
} while (currentArticle.isRedirect() && currentOffset != lastOffset);
|
|
||||||
|
|
||||||
/* Add articles to the queue */
|
if (!currentArticle.isRedirect()) {
|
||||||
indexerToken token;
|
/* Add articles to the queue */
|
||||||
token.title = currentArticle.getTitle();
|
indexerToken token;
|
||||||
token.url = currentArticle.getLongUrl();
|
token.title = currentArticle.getTitle();
|
||||||
token.content = string(currentArticle.getData().data(), currentArticle.getData().size());
|
token.url = currentArticle.getLongUrl();
|
||||||
self->pushToParseQueue(token);
|
token.content = string(currentArticle.getData().data(), currentArticle.getData().size());
|
||||||
|
self->pushToParseQueue(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentOffset++;
|
||||||
|
|
||||||
/* Test if the thread should be cancelled */
|
/* Test if the thread should be cancelled */
|
||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
|
@ -200,6 +201,7 @@ namespace kiwix {
|
||||||
unsigned indexedArticleCount = 0;
|
unsigned indexedArticleCount = 0;
|
||||||
unsigned int articleCount = self->getArticleCount();
|
unsigned int articleCount = self->getArticleCount();
|
||||||
unsigned int currentProgression = self->getProgression();
|
unsigned int currentProgression = self->getProgression();
|
||||||
|
unsigned int tmpProgression;
|
||||||
|
|
||||||
self->indexingPrelude(self->getIndexPath());
|
self->indexingPrelude(self->getIndexPath());
|
||||||
|
|
||||||
|
@ -217,9 +219,10 @@ namespace kiwix {
|
||||||
indexedArticleCount += 1;
|
indexedArticleCount += 1;
|
||||||
|
|
||||||
/* Update the progression counter (in percent) */
|
/* Update the progression counter (in percent) */
|
||||||
if ((unsigned int)((float)indexedArticleCount/(float)articleCount*100) > currentProgression) {
|
tmpProgression = (unsigned int)((float)indexedArticleCount/(float)articleCount*100);
|
||||||
self->setProgression((unsigned int)((float)indexedArticleCount/(float)articleCount*100));
|
if (tmpProgression > currentProgression) {
|
||||||
currentProgression = self->getProgression();
|
currentProgression = tmpProgression;
|
||||||
|
self->setProgression(currentProgression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a hard-disk flush every 10.000 articles */
|
/* Make a hard-disk flush every 10.000 articles */
|
||||||
|
@ -231,13 +234,13 @@ namespace kiwix {
|
||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
}
|
}
|
||||||
self->indexingPostlude();
|
self->indexingPostlude();
|
||||||
|
self->setProgression(100);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
#else
|
#else
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
self->articleIndexerRunning(false);
|
self->articleIndexerRunning(false);
|
||||||
self->setProgression(100);
|
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue