logic: Fixed refreshing when source paths were removed

* Define exit state for TaskRepeatWhileSuccess
* Added TaskFinishParsing to end of parsing task sequence
* Also measure time spend clearing files in total index time
This commit is contained in:
Eberhard Graether
2016-09-29 14:58:45 +02:00
parent e5cd905670
commit 3dffd55f75
15 changed files with 202 additions and 80 deletions
+4 -11
View File
@@ -6,7 +6,6 @@
#include "utility/Cache.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageClearErrorCount.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/text/TextAccess.h"
@@ -364,19 +363,12 @@ void PersistentStorage::logStats() const
LOG_INFO(ss.str());
}
void PersistentStorage::startParsing()
{
clearCaches();
MessageClearErrorCount().dispatch();
m_sqliteStorage.setVersion();
}
void PersistentStorage::finishParsing()
void PersistentStorage::buildCaches()
{
TRACE();
clearCaches();
buildSearchIndex();
buildFilePathMaps();
buildHierarchyCache();
@@ -387,6 +379,7 @@ void PersistentStorage::optimizeMemory()
TRACE();
m_sqliteStorage.optimizeMemory();
m_sqliteStorage.setVersion();
}
Id PersistentStorage::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const
+1 -2
View File
@@ -67,8 +67,7 @@ public:
void logStats() const;
void startParsing();
void finishParsing();
void buildCaches();
void optimizeMemory();
+6
View File
@@ -2,6 +2,8 @@
#include "component/view/DialogView.h"
#include "data/PersistentStorage.h"
#include "utility/scheduling/Blackboard.h"
#include "utility/utility.h"
TaskCleanStorage::TaskCleanStorage(
PersistentStorage* storage, const std::vector<FilePath>& filePaths, DialogView* dialogView
@@ -15,6 +17,8 @@ TaskCleanStorage::TaskCleanStorage(
void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
{
m_dialogView->showProgressDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
m_start = utility::durationStart();
}
Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
@@ -28,6 +32,8 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
void TaskCleanStorage::doExit(std::shared_ptr<Blackboard> blackboard)
{
blackboard->set("clear_time", utility::duration(m_start));
m_dialogView->hideProgressDialog();
}
+3
View File
@@ -5,6 +5,7 @@
#include "utility/file/FilePath.h"
#include "utility/scheduling/Task.h"
#include "utility/TimePoint.h"
class DialogView;
class PersistentStorage;
@@ -28,6 +29,8 @@ private:
PersistentStorage* m_storage;
std::vector<FilePath> m_filePaths;
DialogView* m_dialogView;
TimePoint m_start;
};
#endif // TASK_CLEAN_STORAGE_H
+74
View File
@@ -0,0 +1,74 @@
#include "data/TaskFinishParsing.h"
#include "component/view/DialogView.h"
#include "data/PersistentStorage.h"
#include "utility/file/FileRegister.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/scheduling/Blackboard.h"
#include "utility/utility.h"
TaskFinishParsing::TaskFinishParsing(
PersistentStorage* storage,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
)
: m_storage(storage)
, m_fileRegister(fileRegister)
, m_dialogView(dialogView)
{
}
TaskFinishParsing::~TaskFinishParsing()
{
}
void TaskFinishParsing::doEnter(std::shared_ptr<Blackboard> blackboard)
{
}
Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboard)
{
TimePoint start = utility::durationStart();
m_dialogView->showProgressDialog("Finish Indexing", "Optimizing database");
m_storage->optimizeMemory();
m_dialogView->showProgressDialog("Finish Indexing", "Building caches");
m_storage->buildCaches();
m_dialogView->hideProgressDialog();
MessageFinishedParsing().dispatch();
float time = utility::duration(start);
if (blackboard->exists("clear_time"))
{
float clearTime = 0;
blackboard->get("clear_time", clearTime);
time += clearTime;
}
if (blackboard->exists("index_time"))
{
float indexTime = 0;
blackboard->get("index_time", indexTime);
time += indexTime;
}
m_dialogView->finishedIndexingDialog(
m_fileRegister->getParsedSourceFilesCount(),
m_fileRegister->getSourceFilesCount(),
time,
m_storage->getErrorCount()
);
return STATE_SUCCESS;
}
void TaskFinishParsing::doExit(std::shared_ptr<Blackboard> blackboard)
{
}
void TaskFinishParsing::doReset(std::shared_ptr<Blackboard> blackboard)
{
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef TASK_FINISH_PARSING_H
#define TASK_FINISH_PARSING_H
#include <vector>
#include "utility/file/FilePath.h"
#include "utility/scheduling/Task.h"
class DialogView;
class FileRegister;
class PersistentStorage;
class TaskFinishParsing
: public Task
{
public:
TaskFinishParsing(
PersistentStorage* storage,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
);
virtual ~TaskFinishParsing();
private:
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
PersistentStorage* m_storage;
std::shared_ptr<FileRegister> m_fileRegister;
DialogView* m_dialogView;
};
#endif // TASK_FINISH_PARSING_H
+2 -25
View File
@@ -1,19 +1,15 @@
#include "data/parser/TaskParseWrapper.h"
#include "component/view/DialogView.h"
#include "data/PersistentStorage.h"
#include "utility/file/FileRegister.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/scheduling/Blackboard.h"
#include "utility/utility.h"
TaskParseWrapper::TaskParseWrapper(
PersistentStorage* storage,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
)
: m_storage(storage)
, m_fileRegister(fileRegister)
: m_fileRegister(fileRegister)
, m_dialogView(dialogView)
{
}
@@ -36,7 +32,6 @@ void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
m_dialogView->updateIndexingDialog(0, m_fileRegister->getSourceFilesCount(), "");
m_start = utility::durationStart();
m_storage->startParsing();
}
Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr<Blackboard> blackboard)
@@ -47,25 +42,7 @@ Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr<Blackboard> blackboar
void TaskParseWrapper::doExit(std::shared_ptr<Blackboard> blackboard)
{
blackboard->clear("indexer_count");
m_dialogView->showProgressDialog("Finish Indexing", "Optimizing database");
m_storage->optimizeMemory();
m_dialogView->showProgressDialog("Finish Indexing", "Building caches");
m_storage->finishParsing();
m_dialogView->hideProgressDialog();
MessageFinishedParsing().dispatch();
m_dialogView->finishedIndexingDialog(
m_fileRegister->getParsedSourceFilesCount(),
m_fileRegister->getSourceFilesCount(),
utility::duration(m_start),
m_storage->getErrorCount()
);
blackboard->set("index_time", utility::duration(m_start));
}
void TaskParseWrapper::doReset(std::shared_ptr<Blackboard> blackboard)
-3
View File
@@ -12,14 +12,12 @@
class DialogView;
class FileRegister;
class PersistentStorage;
class TaskParseWrapper
: public TaskDecorator
{
public:
TaskParseWrapper(
PersistentStorage* storage,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
);
@@ -33,7 +31,6 @@ private:
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
PersistentStorage* m_storage;
std::shared_ptr<FileRegister> m_fileRegister;
DialogView* m_dialogView;