Changeset View
Changeset View
Standalone View
Standalone View
src/file/indexcleaner.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #include "indexcleaner.h" | 20 | #include "indexcleaner.h" | ||
21 | #include "fileindexerconfig.h" | 21 | #include "fileindexerconfig.h" | ||
22 | 22 | | |||
23 | #include "database.h" | 23 | #include "database.h" | ||
24 | #include "transaction.h" | 24 | #include "transaction.h" | ||
25 | #include "idutils.h" | 25 | #include "idutils.h" | ||
26 | 26 | | |||
27 | #include <QDebug> | 27 | #include "baloodebug.h" | ||
28 | | ||||
28 | #include <QFile> | 29 | #include <QFile> | ||
29 | #include <QMimeDatabase> | 30 | #include <QMimeDatabase> | ||
30 | 31 | | |||
31 | using namespace Baloo; | 32 | using namespace Baloo; | ||
32 | 33 | | |||
33 | IndexCleaner::IndexCleaner(Database* db, FileIndexerConfig* config) | 34 | IndexCleaner::IndexCleaner(Database* db, FileIndexerConfig* config) | ||
34 | : m_db(db) | 35 | : m_db(db) | ||
35 | , m_config(config) | 36 | , m_config(config) | ||
Show All 11 Lines | 43 | { | |||
47 | auto shouldDelete = [&](quint64 id) { | 48 | auto shouldDelete = [&](quint64 id) { | ||
48 | if (!id) { | 49 | if (!id) { | ||
49 | return false; | 50 | return false; | ||
50 | } | 51 | } | ||
51 | 52 | | |||
52 | QString url = tr.documentUrl(id); | 53 | QString url = tr.documentUrl(id); | ||
53 | 54 | | |||
54 | if (!QFile::exists(url)) { | 55 | if (!QFile::exists(url)) { | ||
55 | qDebug() << "not exists: " << url; | 56 | qCDebug(BALOO) << "not exists: " << url; | ||
56 | return true; | 57 | return true; | ||
57 | } | 58 | } | ||
58 | 59 | | |||
59 | if (!m_config->shouldBeIndexed(url)) { | 60 | if (!m_config->shouldBeIndexed(url)) { | ||
60 | qDebug() << "should not be indexed: " << url; | 61 | qCDebug(BALOO) << "should not be indexed: " << url; | ||
61 | return true; | 62 | return true; | ||
62 | } | 63 | } | ||
63 | 64 | | |||
64 | // FIXME: This mimetype is not completely accurate! | 65 | // FIXME: This mimetype is not completely accurate! | ||
65 | QString mimetype = mimeDb.mimeTypeForFile(url, QMimeDatabase::MatchExtension).name(); | 66 | QString mimetype = mimeDb.mimeTypeForFile(url, QMimeDatabase::MatchExtension).name(); | ||
66 | if (!m_config->shouldMimeTypeBeIndexed(mimetype)) { | 67 | if (!m_config->shouldMimeTypeBeIndexed(mimetype)) { | ||
67 | qDebug() << "mimetype should not be indexed: " << url << mimetype; | 68 | qCDebug(BALOO) << "mimetype should not be indexed: " << url << mimetype; | ||
68 | return true; | 69 | return true; | ||
69 | } | 70 | } | ||
70 | 71 | | |||
71 | return false; | 72 | return false; | ||
72 | }; | 73 | }; | ||
73 | 74 | | |||
74 | const auto includeFolders = m_config->includeFolders(); | 75 | const auto includeFolders = m_config->includeFolders(); | ||
75 | for (const QString& folder : includeFolders) { | 76 | for (const QString& folder : includeFolders) { | ||
76 | quint64 id = filePathToId(QFile::encodeName(folder)); | 77 | quint64 id = filePathToId(QFile::encodeName(folder)); | ||
77 | tr.removeRecursively(id, shouldDelete); | 78 | tr.removeRecursively(id, shouldDelete); | ||
78 | } | 79 | } | ||
79 | tr.commit(); | 80 | tr.commit(); | ||
80 | 81 | | |||
81 | Q_EMIT done(); | 82 | Q_EMIT done(); | ||
82 | } | 83 | } |