logic: Allow duplicate indexing of source files if the indexer command is different
This commit is contained in:
@@ -4,11 +4,21 @@
|
||||
#include <random>
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
void IndexerCommandList::addCommand(std::shared_ptr<IndexerCommand> command)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_commandsMutex);
|
||||
m_commands.push_back(command);
|
||||
|
||||
std::string commandHash = command->getSourceFilePath().str() + std::to_string(command->getByteSize(1));
|
||||
if (m_commandIndex.insert(commandHash).second == true) // Don't add duplicate indexer commands
|
||||
{
|
||||
m_commands.push_back(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Duplicate indexer command was ignored: " << commandHash);
|
||||
}
|
||||
}
|
||||
|
||||
size_t IndexerCommandList::size() const
|
||||
|
||||
@@ -23,6 +23,8 @@ public:
|
||||
private:
|
||||
std::deque<std::shared_ptr<IndexerCommand>> m_commands;
|
||||
std::mutex m_commandsMutex;
|
||||
|
||||
std::set<std::string> m_commandIndex;
|
||||
};
|
||||
|
||||
#endif // INDEXER_COMMAND_LIST_H
|
||||
|
||||
@@ -420,11 +420,10 @@ void Project::buildIndex(
|
||||
));
|
||||
}
|
||||
|
||||
std::set<FilePath> filesToIndexTemp = filesToIndex;
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList = std::make_shared<IndexerCommandList>();
|
||||
for (const std::shared_ptr<SourceGroup>& sourceGroup : m_sourceGroups)
|
||||
{
|
||||
for (const std::shared_ptr<IndexerCommand>& command : sourceGroup->getIndexerCommands(&filesToIndexTemp, fullRefresh))
|
||||
for (const std::shared_ptr<IndexerCommand>& command : sourceGroup->getIndexerCommands(filesToIndex, fullRefresh))
|
||||
{
|
||||
indexerCommandList->addCommand(command);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
std::set<FilePath> getSourceFilePathsToIndex() const;
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh) = 0;
|
||||
const std::set<FilePath>& filesToIndex, bool fullRefresh) = 0;
|
||||
|
||||
protected:
|
||||
std::set<FilePath> getIndexedPaths();
|
||||
|
||||
Reference in New Issue
Block a user