shared: DirscanWorker: Use WildcardMatcher to ignore paths

This commit is contained in:
Albert S. 2022-05-31 10:14:39 +02:00
parent edc41d6f59
commit a3666f283e
2 changed files with 14 additions and 4 deletions

View File

@ -7,7 +7,7 @@ DirScanWorker::DirScanWorker(ConcurrentQueue<QString> &queue, ConcurrentQueue<QS
{
this->queue = &queue;
this->resultQueue = &resultQueue;
this->ignorePattern = ignorePattern;
this->wildcardMatcher.setPatterns(ignorePattern);
this->progressReportThreshold = progressReportThreshold;
this->stopToken = &stopToken;
setAutoDelete(false);
@ -24,10 +24,19 @@ void DirScanWorker::run()
start new DirScanWorkers ourselves here... */
while(queue->dequeue(path))
{
QDirIterator iterator(path, ignorePattern, QDir::Files, QDirIterator::Subdirectories);
if(wildcardMatcher.match(path))
{
continue;
}
QDirIterator iterator(path, QStringList{}, QDir::Files, QDirIterator::Subdirectories);
while(iterator.hasNext())
{
this->results.append(iterator.next());
QString entry = iterator.next();
if(wildcardMatcher.match(entry))
{
continue;
}
this->results.append(entry);
++currentProgress;
if(currentProgress == progressReportThreshold)
{

View File

@ -4,6 +4,7 @@
#include <QRunnable>
#include <QDirIterator>
#include "concurrentqueue.h"
#include "wildcardmatcher.h"
class DirScanWorker : public QObject, public QRunnable
{
Q_OBJECT
@ -12,7 +13,7 @@ class DirScanWorker : public QObject, public QRunnable
ConcurrentQueue<QString> *queue = nullptr;
ConcurrentQueue<QString> *resultQueue = nullptr;
QStringList ignorePattern;
WildcardMatcher wildcardMatcher;
QVector<QString> results;
std::atomic<bool> *stopToken;