diff --git a/qpp/prefetch/Source/Core/ReadFile/read_file.h b/qpp/prefetch/Source/Core/ReadFile/read_file.h index ef9bf68..3ea2ddd 100644 --- a/qpp/prefetch/Source/Core/ReadFile/read_file.h +++ b/qpp/prefetch/Source/Core/ReadFile/read_file.h @@ -16,7 +16,7 @@ class ReadFile : public QThread // Queue thread for later use // Start threadpool after iterate complete to reduce I/O fragment - static void run_scanFolder_createReadFileThread_ququeThread(QString filePath); + static void run_scanFolder_createReadFileThread_ququeThread(QString filePath, bool skipSearch = false); // Save running sleep thread address for later access on other thread static SleepThread *sleepThreadAddress; @@ -50,7 +50,7 @@ class ReadFile : public QThread // Convert config file option to QT thread enum static QMap priorityMap; - // Read all file in QFileInfoList + // Read all file in QFileInfoList static void run_scanFolder_createReadFileThread(QDir *prefetchFolder); // Iterated function diff --git a/qpp/prefetch/Source/Core/ReadFile/run.cpp b/qpp/prefetch/Source/Core/ReadFile/run.cpp index f665a45..f3a9375 100644 --- a/qpp/prefetch/Source/Core/ReadFile/run.cpp +++ b/qpp/prefetch/Source/Core/ReadFile/run.cpp @@ -107,9 +107,11 @@ bool ReadFile::run_runThreadPool(int rescanInterval) return true; } -void ReadFile::run_scanFolder_createReadFileThread_ququeThread(QString filePath) +void ReadFile::run_scanFolder_createReadFileThread_ququeThread(QString filePath, bool skipSearch) { auto readThread = new ReadThread(filePath); + readThread->skipSearch = skipSearch; + ReadFile::readThreadQueue.append(readThread); } diff --git a/qpp/prefetch/Source/Core/Thread/read_thread.cpp b/qpp/prefetch/Source/Core/Thread/read_thread.cpp index 5a706cc..cb19b7b 100644 --- a/qpp/prefetch/Source/Core/Thread/read_thread.cpp +++ b/qpp/prefetch/Source/Core/Thread/read_thread.cpp @@ -100,15 +100,20 @@ void ReadThread::run() return; } - bool priorityInclude = run_SearchInclude(); - - // Only search excluded if file not priority included - if (priorityInclude == false) + if (skipSearch == false) { - if (run_SearchExclude()) + bool priorityInclude = run_SearchInclude(); + + // Only search excluded if file not priority included + if (priorityInclude == false) { - return; + if (run_SearchExclude()) + { + return; + } } + + skipSearch = true; } run_read(); diff --git a/qpp/prefetch/Source/Core/Thread/read_thread.h b/qpp/prefetch/Source/Core/Thread/read_thread.h index d6aac2d..8658134 100644 --- a/qpp/prefetch/Source/Core/Thread/read_thread.h +++ b/qpp/prefetch/Source/Core/Thread/read_thread.h @@ -34,6 +34,10 @@ class ReadThread : public QRunnable // Save file path QString filePath; + // Assume each file is created from cache first + // Modify to false if created from search + bool skipSearch; + private: // Prevent access stdio at same time static QMutex printLock; diff --git a/qpp/prefetch/Source/Core/scan_cache.cpp b/qpp/prefetch/Source/Core/scan_cache.cpp index ef87db3..41aaf37 100644 --- a/qpp/prefetch/Source/Core/scan_cache.cpp +++ b/qpp/prefetch/Source/Core/scan_cache.cpp @@ -85,7 +85,8 @@ void ScanCache::loadScanCache(QList *readThreadQueueAddress) auto getSize = Setting::getInt(MetaData, Size, cache); auto size = getSize.result; - Setting_getOrderedArrayValue_macro(ScanFolder, size, ReadFile::run_scanFolder_createReadFileThread_ququeThread, cache); +#define valueCallback(foo) ReadFile::run_scanFolder_createReadFileThread_ququeThread(foo, true) + Setting_getOrderedArrayValue_macro(ScanFolder, size, valueCallback, cache); } void ScanCache::expireCache()