Changeset View
Changeset View
Standalone View
Standalone View
src/file/fileindexscheduler.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 114 | if (!m_xattrFiles.isEmpty()) { | |||
---|---|---|---|---|---|
117 | 117 | | |||
118 | m_threadPool.start(runnable); | 118 | m_threadPool.start(runnable); | ||
119 | m_xattrFiles.clear(); | 119 | m_xattrFiles.clear(); | ||
120 | m_indexerState = XAttrFiles; | 120 | m_indexerState = XAttrFiles; | ||
121 | Q_EMIT stateChanged(m_indexerState); | 121 | Q_EMIT stateChanged(m_indexerState); | ||
122 | return; | 122 | return; | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | // This should be above content indexing, because there can be files that should not be indexed in the DB | ||||
bruns: Should read "This has to be above ...", also do the line break at ~ 80 chars | |||||
126 | // (i.e. if config was changed) | ||||
127 | if (m_checkStaleIndexEntries) { | ||||
128 | auto runnable = new IndexCleaner(m_db, m_config); | ||||
129 | connect(runnable, &IndexCleaner::done, this, &FileIndexScheduler::scheduleIndexing); | ||||
130 | | ||||
131 | m_threadPool.start(runnable); | ||||
132 | m_checkStaleIndexEntries = false; | ||||
133 | m_indexerState = StaleIndexEntriesClean; | ||||
134 | Q_EMIT stateChanged(m_indexerState); | ||||
135 | return; | ||||
136 | } | ||||
137 | | ||||
125 | if (m_provider.size() && !m_powerMonitor.isOnBattery()) { | 138 | if (m_provider.size() && !m_powerMonitor.isOnBattery()) { | ||
126 | m_threadPool.start(m_contentIndexer); | 139 | m_threadPool.start(m_contentIndexer); | ||
127 | m_indexerState = ContentIndexing; | 140 | m_indexerState = ContentIndexing; | ||
128 | Q_EMIT stateChanged(m_indexerState); | 141 | Q_EMIT stateChanged(m_indexerState); | ||
129 | return; | 142 | return; | ||
130 | } | 143 | } | ||
131 | 144 | | |||
132 | if (m_checkUnindexedFiles) { | 145 | if (m_checkUnindexedFiles) { | ||
133 | auto runnable = new UnindexedFileIndexer(m_db, m_config); | 146 | auto runnable = new UnindexedFileIndexer(m_db, m_config); | ||
134 | connect(runnable, &UnindexedFileIndexer::done, this, &FileIndexScheduler::scheduleIndexing); | 147 | connect(runnable, &UnindexedFileIndexer::done, this, &FileIndexScheduler::scheduleIndexing); | ||
135 | 148 | | |||
136 | m_threadPool.start(runnable); | 149 | m_threadPool.start(runnable); | ||
137 | m_checkUnindexedFiles = false; | 150 | m_checkUnindexedFiles = false; | ||
138 | m_indexerState = UnindexedFileCheck; | 151 | m_indexerState = UnindexedFileCheck; | ||
139 | Q_EMIT stateChanged(m_indexerState); | 152 | Q_EMIT stateChanged(m_indexerState); | ||
140 | return; | 153 | return; | ||
141 | } | 154 | } | ||
142 | 155 | | |||
143 | if (m_checkStaleIndexEntries) { | | |||
144 | auto runnable = new IndexCleaner(m_db, m_config); | | |||
145 | connect(runnable, &IndexCleaner::done, this, &FileIndexScheduler::scheduleIndexing); | | |||
146 | | ||||
147 | m_threadPool.start(runnable); | | |||
148 | m_checkStaleIndexEntries = false; | | |||
149 | m_indexerState = StaleIndexEntriesClean; | | |||
150 | Q_EMIT stateChanged(m_indexerState); | | |||
151 | return; | | |||
152 | } | | |||
153 | m_indexerState = Idle; | 156 | m_indexerState = Idle; | ||
154 | Q_EMIT stateChanged(m_indexerState); | 157 | Q_EMIT stateChanged(m_indexerState); | ||
155 | } | 158 | } | ||
156 | 159 | | |||
157 | static void removeStartsWith(QStringList& list, const QString& dir) | 160 | static void removeStartsWith(QStringList& list, const QString& dir) | ||
158 | { | 161 | { | ||
159 | const auto tail = std::remove_if(list.begin(), list.end(), | 162 | const auto tail = std::remove_if(list.begin(), list.end(), | ||
160 | [&dir](const QString& file) { | 163 | [&dir](const QString& file) { | ||
161 | return file.startsWith(dir); | 164 | return file.startsWith(dir); | ||
162 | }); | 165 | }); | ||
163 | list.erase(tail, list.end()); | 166 | list.erase(tail, list.end()); | ||
164 | } | 167 | } | ||
165 | 168 | | |||
169 | static void removeShouldNotIndex(QStringList& list, FileIndexerConfig* config) | ||||
170 | { | ||||
171 | const auto tail = std::remove_if(list.begin(), list.end(), | ||||
172 | [config](const QString& file) { | ||||
173 | return !config->shouldBeIndexed(file); | ||||
174 | }); | ||||
175 | list.erase(tail, list.end()); | ||||
176 | } | ||||
177 | | ||||
178 | void FileIndexScheduler::updateConfig() | ||||
179 | { | ||||
180 | // Rescheduling content indexer | ||||
181 | // (so we won't keep indexing files that should not be, bug 373430) | ||||
"Interrupt content indexer, to avoid indexing files that should not be indexed, bug 373430)" bruns: "Interrupt content indexer, to avoid indexing files that should not be indexed, bug 373430)" | |||||
182 | if (m_indexerState == ContentIndexing) { | ||||
183 | m_contentIndexer->quit(); | ||||
184 | m_indexerState = Idle; | ||||
185 | } | ||||
186 | removeShouldNotIndex(m_newFiles, m_config); | ||||
187 | removeShouldNotIndex(m_modifiedFiles, m_config); | ||||
188 | removeShouldNotIndex(m_xattrFiles, m_config); | ||||
189 | checkStaleIndexEntries(); | ||||
replace these two lines by m_checkStaleIndexEntries = true; m_checkUnindexedFiles = true; scheduleIndexing(); bruns: replace these two lines by
```
m_checkStaleIndexEntries = true;
m_checkUnindexedFiles =… | |||||
190 | checkUnindexedFiles(); | ||||
191 | } | ||||
192 | | ||||
166 | void FileIndexScheduler::handleFileRemoved(const QString& file) | 193 | void FileIndexScheduler::handleFileRemoved(const QString& file) | ||
167 | { | 194 | { | ||
168 | if (!file.endsWith(QLatin1Char('/'))) { | 195 | if (!file.endsWith(QLatin1Char('/'))) { | ||
169 | m_newFiles.removeOne(file); | 196 | m_newFiles.removeOne(file); | ||
170 | m_modifiedFiles.removeOne(file); | 197 | m_modifiedFiles.removeOne(file); | ||
171 | m_xattrFiles.removeOne(file); | 198 | m_xattrFiles.removeOne(file); | ||
172 | } | 199 | } | ||
173 | else { | 200 | else { | ||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |
Should read "This has to be above ...", also do the line break at ~ 80 chars