logic: Added full refresh checkbox to indexing start dialog
* Checkbox allows for switching between refresh and full refresh * Renamed menu option Force Refresh to Full Refresh * Checkbox is not visible when project needs to be fully refreshed
This commit is contained in:
@@ -298,7 +298,7 @@ add_files(
|
||||
utility/messaging/type/MessageWindowClosed.h
|
||||
utility/messaging/type/MessageWindowFocus.h
|
||||
utility/messaging/type/MessageZoom.h
|
||||
|
||||
|
||||
utility/messaging/Message.h
|
||||
utility/messaging/MessageBase.h
|
||||
utility/messaging/MessageInterruptTasksCounter.cpp
|
||||
@@ -327,7 +327,6 @@ add_files(
|
||||
utility/scheduling/TaskGroupSequence.h
|
||||
utility/scheduling/TaskLambda.cpp
|
||||
utility/scheduling/TaskLambda.h
|
||||
utility/scheduling/TaskReturnSuccessWhile.cpp
|
||||
utility/scheduling/TaskReturnSuccessWhile.h
|
||||
utility/scheduling/TaskRunner.cpp
|
||||
utility/scheduling/TaskRunner.h
|
||||
|
||||
+83
-71
@@ -43,52 +43,50 @@ bool Project::refresh(bool forceRefresh)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needsFullRefresh = false;
|
||||
std::string question;
|
||||
|
||||
if (!forceRefresh)
|
||||
switch (m_state)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case PROJECT_STATE_EMPTY:
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_EMPTY:
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_LOADED:
|
||||
break;
|
||||
case PROJECT_STATE_LOADED:
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_OUTDATED:
|
||||
question =
|
||||
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
|
||||
"reflect the current project state. Do you want to reindex the project?";
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_OUTDATED:
|
||||
question =
|
||||
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
|
||||
"reflect the current project state. Do you want to reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_OUTVERSIONED:
|
||||
question =
|
||||
"This project was indexed with a different version of Coati. It needs to be fully reindexed to be used "
|
||||
"with this version of Coati. Do you want to reindex the project?";
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_OUTVERSIONED:
|
||||
question =
|
||||
"This project was indexed with a different version of Coati. It needs to be fully reindexed to be used "
|
||||
"with this version of Coati. Do you want to reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_SETTINGS_UPDATED:
|
||||
question =
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?";
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_SETTINGS_UPDATED:
|
||||
question =
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_NEEDS_MIGRATION:
|
||||
question =
|
||||
"This project was created with a different version of Coati. The project file needs to get updated and "
|
||||
"the project fully reindexed. Do you want to update the project file and reindex the project?";
|
||||
forceRefresh = true;
|
||||
case PROJECT_STATE_NEEDS_MIGRATION:
|
||||
question =
|
||||
"This project was created with a different version of Coati. The project file needs to get updated and "
|
||||
"the project fully reindexed. Do you want to update the project file and reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (forceRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
if (!forceRefresh && needsFullRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
@@ -115,7 +113,7 @@ bool Project::refresh(bool forceRefresh)
|
||||
|
||||
updateFileManager(m_fileManager);
|
||||
|
||||
if (buildIndex(forceRefresh))
|
||||
if (requestIndex(forceRefresh, needsFullRefresh))
|
||||
{
|
||||
m_storageAccessProxy->setSubject(m_storage.get());
|
||||
|
||||
@@ -242,66 +240,84 @@ void Project::load()
|
||||
}
|
||||
}
|
||||
|
||||
bool Project::buildIndex(bool forceRefresh)
|
||||
bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
{
|
||||
if (!prepareIndexing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FileInfo> fileInfos = m_storage->getInfoOnAllFiles();
|
||||
|
||||
m_fileManager.fetchFilePaths(forceRefresh ? std::vector<FileInfo>() : fileInfos);
|
||||
|
||||
std::set<FilePath> addedFilePaths = m_fileManager.getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager.getUpdatedFilePaths();
|
||||
std::set<FilePath> removedFilePaths = m_fileManager.getRemovedFilePaths();
|
||||
FileManager::FileSets fileSets = m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
|
||||
std::set<FilePath> filesToClean;
|
||||
std::set<FilePath> filesToParse;
|
||||
std::set<FilePath> filesToIndex;
|
||||
|
||||
if (!forceRefresh)
|
||||
if (!needsFullRefresh)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(updatedFilePaths));
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(removedFilePaths));
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(fileSets.updatedFiles));
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(fileSets.removedFiles));
|
||||
|
||||
for (const FilePath& path : dependingFilePaths)
|
||||
{
|
||||
if (removedFilePaths.find(path) == removedFilePaths.end())
|
||||
if (fileSets.removedFiles.find(path) == fileSets.removedFiles.end())
|
||||
{
|
||||
updatedFilePaths.insert(path);
|
||||
fileSets.updatedFiles.insert(path);
|
||||
}
|
||||
}
|
||||
|
||||
utility::append(filesToClean, fileSets.removedFiles);
|
||||
utility::append(filesToClean, fileSets.updatedFiles);
|
||||
utility::append(filesToClean, dependingFilePaths);
|
||||
|
||||
utility::append(filesToIndex, fileSets.addedFiles);
|
||||
utility::append(filesToIndex, fileSets.updatedFiles);
|
||||
}
|
||||
|
||||
utility::append(filesToClean, removedFilePaths);
|
||||
utility::append(filesToClean, updatedFilePaths);
|
||||
bool fullRefresh = forceRefresh | needsFullRefresh;
|
||||
|
||||
utility::append(filesToParse, addedFilePaths);
|
||||
utility::append(filesToParse, updatedFilePaths);
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
DialogView::IndexMode mode = m_dialogView->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), fileSets.allFiles.size(),
|
||||
forceRefresh, needsFullRefresh
|
||||
);
|
||||
|
||||
if (!filesToClean.size() && !filesToParse.size() && (!forceRefresh || !fileInfos.size()))
|
||||
switch (mode)
|
||||
{
|
||||
case DialogView::INDEX_ABORT:
|
||||
return false;
|
||||
case DialogView::INDEX_REFRESH:
|
||||
fullRefresh = false;
|
||||
break;
|
||||
case DialogView::INDEX_FULL:
|
||||
fullRefresh = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fullRefresh)
|
||||
{
|
||||
filesToClean.clear();
|
||||
filesToIndex = fileSets.allFiles;
|
||||
}
|
||||
|
||||
if (!filesToClean.size() && !filesToIndex.size())
|
||||
{
|
||||
MessageStatus("Nothing to refresh, all files are up-to-date.").dispatch();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
bool doIndex = m_dialogView->startIndexingDialog(filesToClean.size(), filesToParse.size());
|
||||
buildIndex(filesToClean, filesToIndex, fullRefresh);
|
||||
|
||||
if (!doIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<FilePath>& filesToIndex, bool fullRefresh)
|
||||
{
|
||||
MessageClearErrorCount().dispatch();
|
||||
|
||||
if (forceRefresh)
|
||||
if (fullRefresh)
|
||||
{
|
||||
m_storage->clear();
|
||||
}
|
||||
@@ -323,9 +339,9 @@ bool Project::buildIndex(bool forceRefresh)
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(&m_fileManager, indexerThreadCount > 1);
|
||||
|
||||
if (!filesToParse.empty())
|
||||
if (!filesToIndex.empty())
|
||||
{
|
||||
fileRegister->setFilePaths(utility::toVector(filesToParse));
|
||||
fileRegister->setFilePaths(utility::toVector(filesToIndex));
|
||||
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(
|
||||
m_storage.get(),
|
||||
@@ -339,7 +355,7 @@ bool Project::buildIndex(bool forceRefresh)
|
||||
|
||||
std::shared_ptr<StorageProvider> storageProvider = std::make_shared<StorageProvider>();
|
||||
|
||||
for (size_t i = 0; i < indexerThreadCount && i < filesToParse.size(); i++)
|
||||
for (size_t i = 0; i < indexerThreadCount && i < filesToIndex.size(); i++)
|
||||
{
|
||||
taskParallelIndexing->addChildTasks(
|
||||
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
|
||||
@@ -378,13 +394,9 @@ bool Project::buildIndex(bool forceRefresh)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
taskSequential->addTask(std::make_shared<TaskFinishParsing>(m_storage.get(), m_storageAccessProxy, fileRegister, m_dialogView));
|
||||
|
||||
Task::dispatch(taskSequential);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Project::prepareIndexing()
|
||||
|
||||
+3
-1
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
@@ -57,7 +58,8 @@ public: // todo: make private again
|
||||
void load();
|
||||
|
||||
private:
|
||||
bool buildIndex(bool forceRefresh);
|
||||
bool requestIndex(bool forceRefresh, bool needsFullRefresh);
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, const std::set<FilePath>& filesToIndex, bool fullRefresh);
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
virtual bool prepareRefresh();
|
||||
|
||||
@@ -17,9 +17,10 @@ void DialogView::hideProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
bool DialogView::startIndexingDialog(size_t cleanFileCount, size_t indexFileCount)
|
||||
{
|
||||
return false;
|
||||
DialogView::IndexMode DialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh
|
||||
){
|
||||
return INDEX_ABORT;
|
||||
}
|
||||
|
||||
void DialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
|
||||
@@ -11,13 +11,21 @@ class StorageAccess;
|
||||
class DialogView
|
||||
{
|
||||
public:
|
||||
enum IndexMode
|
||||
{
|
||||
INDEX_ABORT,
|
||||
INDEX_REFRESH,
|
||||
INDEX_FULL
|
||||
};
|
||||
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
virtual ~DialogView();
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
virtual bool startIndexingDialog(size_t cleanFileCount, size_t indexFileCount);
|
||||
virtual IndexMode startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh);
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath);
|
||||
virtual void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ void FileManager::setPaths(
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
|
||||
void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
FileManager::FileSets FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
{
|
||||
m_files.clear();
|
||||
for (FileInfo oldFileInfo: oldFileInfos)
|
||||
@@ -40,9 +40,7 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
m_files.emplace(oldFileInfo.path, oldFileInfo);
|
||||
}
|
||||
|
||||
m_addedFiles.clear();
|
||||
m_updatedFiles.clear();
|
||||
m_removedFiles.clear();
|
||||
FileSets fileSets;
|
||||
|
||||
for (std::map<FilePath, FileInfo>::iterator it = m_files.begin(); it != m_files.end(); it++)
|
||||
{
|
||||
@@ -54,17 +52,15 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
m_updatedFiles.insert(filePath);
|
||||
fileSets.updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_removedFiles.insert(filePath);
|
||||
fileSets.removedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
m_sourceFiles.clear();
|
||||
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions);
|
||||
for (FileInfo fileInfo: fileInfos)
|
||||
{
|
||||
@@ -74,44 +70,33 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
continue;
|
||||
}
|
||||
|
||||
m_sourceFiles.insert(filePath);
|
||||
fileSets.allFiles.insert(filePath);
|
||||
|
||||
std::map<FilePath, FileInfo>::iterator it = m_files.find(filePath);
|
||||
if (it != m_files.end())
|
||||
{
|
||||
m_removedFiles.erase(filePath);
|
||||
fileSets.removedFiles.erase(filePath);
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
m_updatedFiles.insert(filePath);
|
||||
fileSets.updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_files.insert(std::pair<FilePath, FileInfo>(filePath, fileInfo));
|
||||
m_addedFiles.insert(filePath);
|
||||
fileSets.addedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
for (const FilePath& filePath : m_removedFiles)
|
||||
for (const FilePath& filePath : fileSets.removedFiles)
|
||||
{
|
||||
m_files.erase(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getAddedFilePaths() const
|
||||
{
|
||||
return m_addedFiles;
|
||||
}
|
||||
m_sourceFiles = fileSets.allFiles;
|
||||
|
||||
std::set<FilePath> FileManager::getUpdatedFilePaths() const
|
||||
{
|
||||
return m_updatedFiles;
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getRemovedFilePaths() const
|
||||
{
|
||||
return m_removedFiles;
|
||||
return fileSets;
|
||||
}
|
||||
|
||||
bool FileManager::hasFilePath(const FilePath& filePath) const
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
struct FileSets
|
||||
{
|
||||
std::set<FilePath> allFiles;
|
||||
std::set<FilePath> addedFiles;
|
||||
std::set<FilePath> updatedFiles;
|
||||
std::set<FilePath> removedFiles;
|
||||
};
|
||||
|
||||
FileManager();
|
||||
virtual ~FileManager();
|
||||
|
||||
@@ -22,11 +30,7 @@ public:
|
||||
std::vector<std::string> sourceExtensions
|
||||
);
|
||||
|
||||
void fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
std::set<FilePath> getAddedFilePaths() const;
|
||||
std::set<FilePath> getUpdatedFilePaths() const;
|
||||
std::set<FilePath> getRemovedFilePaths() const;
|
||||
FileSets fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
virtual bool hasFilePath(const FilePath& filePath) const;
|
||||
virtual bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
@@ -45,10 +49,6 @@ private:
|
||||
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
|
||||
std::set<FilePath> m_addedFiles;
|
||||
std::set<FilePath> m_updatedFiles;
|
||||
std::set<FilePath> m_removedFiles;
|
||||
|
||||
std::set<FilePath> m_sourceFiles;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user