Changeset View
Changeset View
Standalone View
Standalone View
src/file/unindexedfileiterator.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 67 | while (1) { | |||
---|---|---|---|---|---|
69 | m_mTimeChanged = false; | 69 | m_mTimeChanged = false; | ||
70 | m_cTimeChanged = false; | 70 | m_cTimeChanged = false; | ||
71 | 71 | | |||
72 | if (filePath.isEmpty()) { | 72 | if (filePath.isEmpty()) { | ||
73 | m_mimetype.clear(); | 73 | m_mimetype.clear(); | ||
74 | return QString(); | 74 | return QString(); | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | // This mimetype may not be completely accurate, but that's okay. This is | 77 | if (shouldIndex(filePath)) { | ||
78 | // just the initial phase of indexing. The second phase can try to find | | |||
79 | // a more accurate mimetype. | | |||
80 | m_mimetype = m_mimeDb.mimeTypeForFile(filePath, QMimeDatabase::MatchExtension).name(); | | |||
81 | | ||||
82 | if (shouldIndex(filePath, m_mimetype)) { | | |||
83 | return filePath; | 78 | return filePath; | ||
84 | } | 79 | } | ||
85 | } | 80 | } | ||
86 | } | 81 | } | ||
87 | 82 | | |||
88 | bool UnIndexedFileIterator::shouldIndex(const QString& filePath, const QString& mimetype) | 83 | bool UnIndexedFileIterator::shouldIndex(const QString& filePath) | ||
89 | { | 84 | { | ||
90 | bool shouldIndexType = m_config->shouldMimeTypeBeIndexed(mimetype); | | |||
91 | if (!shouldIndexType) | | |||
92 | return false; | | |||
93 | | ||||
94 | const QFileInfo fileInfo = m_iter.fileInfo(); | 85 | const QFileInfo fileInfo = m_iter.fileInfo(); | ||
95 | if (!fileInfo.exists()) | 86 | if (!fileInfo.exists()) | ||
96 | return false; | 87 | return false; | ||
97 | 88 | | |||
98 | quint64 fileId = filePathToId(QFile::encodeName(filePath)); | 89 | quint64 fileId = filePathToId(QFile::encodeName(filePath)); | ||
99 | if (!fileId) { | 90 | if (!fileId) { | ||
100 | // stat has failed, e.g. when file has been deleted after iteration | 91 | // stat has failed, e.g. when file has been deleted after iteration | ||
101 | return false; | 92 | return false; | ||
Show All 13 Lines | |||||
115 | } | 106 | } | ||
116 | 107 | | |||
117 | auto fileMTime = fileInfo.metadataChangeTime().toTime_t(); | 108 | auto fileMTime = fileInfo.metadataChangeTime().toTime_t(); | ||
118 | if (timeInfo.cTime != fileMTime) { | 109 | if (timeInfo.cTime != fileMTime) { | ||
119 | m_cTimeChanged = true; | 110 | m_cTimeChanged = true; | ||
120 | } | 111 | } | ||
121 | 112 | | |||
122 | if (m_mTimeChanged || m_cTimeChanged) { | 113 | if (m_mTimeChanged || m_cTimeChanged) { | ||
114 | if (fileInfo.isDir()) { | ||||
115 | m_mimetype = QStringLiteral("inode/directory"); | ||||
116 | return true; | ||||
117 | } | ||||
118 | | ||||
119 | // This mimetype may not be completely accurate, but that's okay. This is | ||||
120 | // just the initial phase of indexing. The second phase can try to find | ||||
121 | // a more accurate mimetype. | ||||
122 | m_mimetype = m_mimeDb.mimeTypeForFile(filePath, QMimeDatabase::MatchExtension).name(); | ||||
123 | if (!m_config->shouldMimeTypeBeIndexed(m_mimetype)) { | ||||
124 | return false; | ||||
125 | } | ||||
126 | | ||||
123 | qCDebug(BALOO) << "mtime/ctime changed:" | 127 | qCDebug(BALOO) << "mtime/ctime changed:" | ||
124 | << timeInfo.mTime << fileInfo.lastModified().toTime_t() | 128 | << timeInfo.mTime << fileInfo.lastModified().toTime_t() | ||
125 | << timeInfo.cTime << fileMTime; | 129 | << timeInfo.cTime << fileMTime; | ||
126 | return true; | 130 | return true; | ||
127 | } | 131 | } | ||
128 | 132 | | |||
129 | return false; | 133 | return false; | ||
130 | } | 134 | } |