Changeset View
Changeset View
Standalone View
Standalone View
src/file/fileindexscheduler.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include "firstrunindexer.h" | 22 | #include "firstrunindexer.h" | ||
23 | #include "newfileindexer.h" | 23 | #include "newfileindexer.h" | ||
24 | #include "modifiedfileindexer.h" | 24 | #include "modifiedfileindexer.h" | ||
25 | #include "xattrindexer.h" | 25 | #include "xattrindexer.h" | ||
26 | #include "filecontentindexer.h" | 26 | #include "filecontentindexer.h" | ||
27 | #include "filecontentindexerprovider.h" | 27 | #include "filecontentindexerprovider.h" | ||
28 | #include "unindexedfileindexer.h" | 28 | #include "unindexedfileindexer.h" | ||
29 | #include "indexcleaner.h" | ||||
29 | 30 | | |||
30 | #include "fileindexerconfig.h" | 31 | #include "fileindexerconfig.h" | ||
31 | 32 | | |||
32 | #include <memory> | 33 | #include <memory> | ||
33 | 34 | | |||
34 | #include <QTimer> | 35 | #include <QTimer> | ||
35 | #include <QDebug> | 36 | #include <QDebug> | ||
36 | #include <QDBusConnection> | 37 | #include <QDBusConnection> | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 84 | if (m_config->isInitialRun() && !m_indexerStates.contains(FirstRun)) { | |||
89 | m_threadPool.start(runnable); | 90 | m_threadPool.start(runnable); | ||
90 | runnableStarted(FirstRun); | 91 | runnableStarted(FirstRun); | ||
91 | 92 | | |||
92 | return; | 93 | return; | ||
93 | } else if (m_indexerStates.contains(FirstRun)) { | 94 | } else if (m_indexerStates.contains(FirstRun)) { | ||
94 | return; | 95 | return; | ||
95 | } | 96 | } | ||
96 | 97 | | |||
98 | if (m_purgeDeindexableFiles && !m_indexerStates.contains(DeindexingFileCheck)) { | ||||
99 | auto runnable = new IndexCleaner(m_db, m_config); | ||||
100 | connect(runnable, &IndexCleaner::done, this, [=] () { | ||||
101 | m_purgeDeindexableFiles = false; | ||||
102 | runnableStopped(DeindexingFileCheck); | ||||
103 | }); | ||||
104 | | ||||
105 | m_threadPool.start(runnable); | ||||
106 | runnableStarted(DeindexingFileCheck); | ||||
107 | } | ||||
108 | | ||||
97 | if (m_checkUnindexedFiles | 109 | if (m_checkUnindexedFiles | ||
98 | && !m_indexerStates.contains(NewFiles) | 110 | && !m_indexerStates.contains(NewFiles) | ||
99 | && !m_indexerStates.contains(UnindexedFileCheck)) { | 111 | && !m_indexerStates.contains(UnindexedFileCheck)) { | ||
100 | auto runnable = new UnindexedFileIndexer(m_db, m_config); | 112 | auto runnable = new UnindexedFileIndexer(m_db, m_config); | ||
101 | connect(runnable, &UnindexedFileIndexer::done, this, [=] () { | 113 | connect(runnable, &UnindexedFileIndexer::done, this, [=] () { | ||
102 | m_checkUnindexedFiles = false; | 114 | m_checkUnindexedFiles = false; | ||
103 | runnableStopped(UnindexedFileCheck); | 115 | runnableStopped(UnindexedFileCheck); | ||
104 | }); | 116 | }); | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 157 | && !m_indexerStates.contains(Suspended)) { | |||
146 | connect(m_contentIndexer, &FileContentIndexer::done, this, [=] () { | 158 | connect(m_contentIndexer, &FileContentIndexer::done, this, [=] () { | ||
147 | runnableStopped(ContentIndexing); | 159 | runnableStopped(ContentIndexing); | ||
148 | }); | 160 | }); | ||
149 | 161 | | |||
150 | m_threadPool.start(m_contentIndexer); | 162 | m_threadPool.start(m_contentIndexer); | ||
151 | runnableStarted(ContentIndexing); | 163 | runnableStarted(ContentIndexing); | ||
152 | } | 164 | } | ||
153 | } | 165 | } | ||
154 | 166 | | |||
michaelh: Same as above | |||||
155 | static void removeStartsWith(QStringList& list, const QString& dir) | 167 | static void removeStartsWith(QStringList& list, const QString& dir) | ||
156 | { | 168 | { | ||
157 | const auto tail = std::remove_if(list.begin(), list.end(), | 169 | const auto tail = std::remove_if(list.begin(), list.end(), | ||
158 | [&dir](const QString& file) { | 170 | [&dir](const QString& file) { | ||
159 | return file.startsWith(dir); | 171 | return file.startsWith(dir); | ||
160 | }); | 172 | }); | ||
161 | list.erase(tail, list.end()); | 173 | list.erase(tail, list.end()); | ||
162 | } | 174 | } | ||
Show All 37 Lines | |||||
200 | uint FileIndexScheduler::getRemainingTime() | 212 | uint FileIndexScheduler::getRemainingTime() | ||
201 | { | 213 | { | ||
202 | if (m_indexerStates.at(0) != ContentIndexing) { | 214 | if (m_indexerStates.at(0) != ContentIndexing) { | ||
203 | return 0; | 215 | return 0; | ||
204 | } | 216 | } | ||
205 | return m_timeEstimator.calculateTimeLeft(m_provider.size()); | 217 | return m_timeEstimator.calculateTimeLeft(m_provider.size()); | ||
206 | } | 218 | } | ||
207 | 219 | | |||
220 | void FileIndexScheduler::updateIndex() | ||||
221 | { | ||||
222 | m_purgeDeindexableFiles = true; | ||||
223 | m_checkUnindexedFiles = true; | ||||
224 | scheduleIndexing(); | ||||
225 | } | ||||
226 | | ||||
208 | void FileIndexScheduler::checkUnindexedFiles() | 227 | void FileIndexScheduler::checkUnindexedFiles() | ||
209 | { | 228 | { | ||
210 | m_checkUnindexedFiles = true; | 229 | m_checkUnindexedFiles = true; | ||
211 | scheduleIndexing(); | 230 | scheduleIndexing(); | ||
212 | } | 231 | } | ||
213 | 232 | | |||
214 | uint FileIndexScheduler::getBatchSize() | 233 | uint FileIndexScheduler::getBatchSize() | ||
michaelh: Same as above | |||||
215 | { | 234 | { | ||
216 | return m_config->maxUncomittedFiles(); | 235 | return m_config->maxUncomittedFiles(); | ||
michaelh: Same as above | |||||
217 | } | 236 | } |
Same as above