shared: DirscanWorker: Use WildcardMatcher to ignore paths

This commit is contained in:
Albert S. 2022-05-31 10:14:39 +02:00
szülő edc41d6f59
commit a3666f283e
2 fájl változott, egészen pontosan 14 új sor hozzáadva és 4 régi sor törölve

Fájl megtekintése

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

Fájl megtekintése

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