mirror of https://github.com/kiwix/libkiwix.git
* FIXED: Abstruse index names (#84)
This commit is contained in:
parent
499b50172f
commit
2d88190f28
|
@ -48,6 +48,7 @@ namespace kiwix {
|
|||
pthread_mutex_init(&articleIndexerRunningMutex, NULL);
|
||||
pthread_mutex_init(&articleCountMutex, NULL);
|
||||
pthread_mutex_init(&zimPathMutex, NULL);
|
||||
pthread_mutex_init(&zimIdMutex, NULL);
|
||||
pthread_mutex_init(&indexPathMutex, NULL);
|
||||
pthread_mutex_init(&progressionMutex, NULL);
|
||||
pthread_mutex_init(&verboseMutex, NULL);
|
||||
|
@ -70,10 +71,12 @@ namespace kiwix {
|
|||
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
|
||||
kiwix::Indexer *self = (kiwix::Indexer *)ptr;
|
||||
|
||||
/* Get the number of article to index */
|
||||
/* Get the number of article to index and the ZIM id */
|
||||
kiwix::Reader reader(self->getZimPath());
|
||||
unsigned int articleCount = reader.getGlobalCount();
|
||||
self->setArticleCount(articleCount);
|
||||
string zimId = reader.getId();
|
||||
self->setZimId(zimId);
|
||||
|
||||
/* Progression */
|
||||
unsigned int readArticleCount = 0;
|
||||
|
@ -237,6 +240,11 @@ namespace kiwix {
|
|||
pthread_testcancel();
|
||||
}
|
||||
self->indexingPostlude();
|
||||
|
||||
/* Write content id file */
|
||||
string path = appendToDirectory(self->getIndexPath(), "content.id");
|
||||
writeTextFile(path, self->getZimId());
|
||||
|
||||
self->setProgression(100);
|
||||
#ifdef _WIN32
|
||||
Sleep(100);
|
||||
|
@ -405,6 +413,19 @@ namespace kiwix {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
void Indexer::setZimId(const string id) {
|
||||
pthread_mutex_lock(&zimIdMutex);
|
||||
this->zimId = id;
|
||||
pthread_mutex_unlock(&zimIdMutex);
|
||||
}
|
||||
|
||||
string Indexer::getZimId() {
|
||||
pthread_mutex_lock(&zimIdMutex);
|
||||
string retVal = this->zimId;
|
||||
pthread_mutex_unlock(&zimIdMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/* Manage */
|
||||
bool Indexer::start(const string zimPath, const string indexPath) {
|
||||
if (this->getVerboseFlag()) {
|
||||
|
|
|
@ -163,6 +163,12 @@ namespace kiwix {
|
|||
string indexPath;
|
||||
void setIndexPath(const string path);
|
||||
string getIndexPath();
|
||||
|
||||
/* ZIM id */
|
||||
pthread_mutex_t zimIdMutex;
|
||||
string zimId;
|
||||
void setZimId(const string id);
|
||||
string getZimId();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,17 @@ string removeLastPathElement(const string path, const bool removePreSeparator, c
|
|||
return newPath;
|
||||
}
|
||||
|
||||
string appendToDirectory(const string &directoryPath, const string &filename) {
|
||||
#ifdef _WIN32
|
||||
string separator = "\\";
|
||||
#else
|
||||
string separator = "/";
|
||||
#endif
|
||||
|
||||
string newPath = directoryPath + separator + filename;
|
||||
return newPath;
|
||||
}
|
||||
|
||||
string getLastPathElement(const string &path) {
|
||||
#ifdef _WIN32
|
||||
string separator = "\\";
|
||||
|
@ -166,3 +177,11 @@ string getExecutablePath() {
|
|||
|
||||
return std::string(binRootPath);
|
||||
}
|
||||
|
||||
bool writeTextFile(const string &path, const string &content) {
|
||||
std::ofstream file;
|
||||
file.open(path);
|
||||
file << content;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ bool isRelativePath(const string &path);
|
|||
string computeAbsolutePath(const string libraryPath, const string relativePath);
|
||||
string removeLastPathElement(const string path, const bool removePreSeparator = false,
|
||||
const bool removePostSeparator = false);
|
||||
string appendToDirectory(const string &directoryPath, const string &filename);
|
||||
|
||||
unsigned int getFileSize(const string &path);
|
||||
string getFileSizeAsString(const string &path);
|
||||
|
@ -51,4 +52,5 @@ bool copyFile(const string &sourcePath, const string &destPath);
|
|||
string getLastPathElement(const string &path);
|
||||
string getExecutablePath();
|
||||
|
||||
bool writeTextFile(const string &path, const string &content);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue