From 0e5abf96c8a01ac54244661928667a905d819fd3 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 5 Jun 2022 20:29:53 +0200 Subject: [PATCH] shared: indexer: Don't dispatch DirScanner if no dirs given This makes sense in general, however it also avoids a race condition. The dirscanner may finish before the filescanworkers for the files run, this then signals the whole indexer has finished. --- shared/indexer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shared/indexer.cpp b/shared/indexer.cpp index 7076b13..3cc7470 100644 --- a/shared/indexer.cpp +++ b/shared/indexer.cpp @@ -36,10 +36,14 @@ void Indexer::beginIndexing() this->filePathTargetsQueue.enqueue(path); } } - this->dirScanner->setPaths(dirs); - this->dirScanner->setIgnorePatterns(this->ignorePattern); - this->dirScanner->scan(); + if(!dirs.empty()) + { + this->dirScanner->setPaths(dirs); + this->dirScanner->setIgnorePatterns(this->ignorePattern); + + this->dirScanner->scan(); + } this->workerCancellationToken.store(false, std::memory_order_seq_cst); launchWorker(this->filePathTargetsQueue, this->filePathTargetsQueue.remaining()); @@ -68,7 +72,7 @@ IndexResult Indexer::getResult() void Indexer::dirScanFinished() { - Logger::info() << "Dir scan finished"; + Logger::info() << "Dir scan finished" << Qt::endl; if(!isRunning()) { emit finished();