Changeset View
Changeset View
Standalone View
Standalone View
src/tools/balooctl/configcommand.cpp
Show All 17 Lines | |||||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "configcommand.h" | 21 | #include "configcommand.h" | ||
22 | #include "indexerconfig.h" | 22 | #include "indexerconfig.h" | ||
23 | 23 | | |||
24 | #include <QTextStream> | 24 | #include <QTextStream> | ||
25 | #include <QFileInfo> | 25 | #include <QFileInfo> | ||
26 | #include <QDir> | ||||
26 | 27 | | |||
27 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
28 | 29 | | |||
29 | using namespace Baloo; | 30 | using namespace Baloo; | ||
30 | 31 | | |||
31 | /* | 32 | /* | ||
32 | * TODO: remove code duplication, we are performing similar operations | 33 | * TODO: remove code duplication, we are performing similar operations | ||
33 | * for excludeFolders, includeFolders and excludeFilters just using different | 34 | * for excludeFolders, includeFolders and excludeFilters just using different | ||
▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Line(s) | 271 | if (value.compare(QLatin1String("includeFolders"), Qt::CaseInsensitive) == 0) { | |||
287 | auto path = fileInfo.absoluteFilePath(); | 288 | auto path = fileInfo.absoluteFilePath(); | ||
288 | QStringList folders = config.includeFolders(); | 289 | QStringList folders = config.includeFolders(); | ||
289 | if (folders.contains(path)) { | 290 | if (folders.contains(path)) { | ||
290 | out << i18n("%1 is already in the list of include folders", path) << endl; | 291 | out << i18n("%1 is already in the list of include folders", path) << endl; | ||
291 | return 1; | 292 | return 1; | ||
292 | } | 293 | } | ||
293 | 294 | | |||
294 | for (const QString& folder : folders) { | 295 | for (const QString& folder : folders) { | ||
295 | if (path.startsWith(folder)) { | 296 | if (path.startsWith(folder + QDir::separator())) { | ||
296 | out << i18n("Parent folder %1 is already in the list of include folders", folder) << endl; | 297 | out << i18n("Parent folder %1 is already in the list of include folders", folder) << endl; | ||
297 | return 1; | 298 | return 1; | ||
298 | } | 299 | } | ||
299 | } | 300 | } | ||
300 | 301 | | |||
301 | if (config.excludeFolders().contains(path)) { | 302 | if (config.excludeFolders().contains(path)) { | ||
302 | out << i18n("%1 is in the list of exclude folders", path) << endl; | 303 | out << i18n("%1 is in the list of exclude folders", path) << endl; | ||
303 | out << "Aborting" << endl; | 304 | out << "Aborting" << endl; | ||
Show All 25 Lines | 313 | if (value.compare(QLatin1String("excludeFolders"), Qt::CaseInsensitive) == 0) { | |||
329 | auto path = fileInfo.absoluteFilePath(); | 330 | auto path = fileInfo.absoluteFilePath(); | ||
330 | QStringList folders = config.excludeFolders(); | 331 | QStringList folders = config.excludeFolders(); | ||
331 | if (folders.contains(path)) { | 332 | if (folders.contains(path)) { | ||
332 | out << i18n("%1 is already in the list of exclude folders", path) << endl; | 333 | out << i18n("%1 is already in the list of exclude folders", path) << endl; | ||
333 | return 1; | 334 | return 1; | ||
334 | } | 335 | } | ||
335 | 336 | | |||
336 | for (const QString& folder : folders) { | 337 | for (const QString& folder : folders) { | ||
337 | if (path.startsWith(folder)) { | 338 | if (path.startsWith(folder + QDir::separator())) { | ||
338 | out << i18n("Parent folder %1 is already in the list of exclude folders", folder) << endl; | 339 | out << i18n("Parent folder %1 is already in the list of exclude folders", folder) << endl; | ||
339 | return 1; | 340 | return 1; | ||
340 | } | 341 | } | ||
341 | } | 342 | } | ||
342 | 343 | | |||
343 | if (config.includeFolders().contains(path)) { | 344 | if (config.includeFolders().contains(path)) { | ||
344 | out << i18n("%1 is in the list of exclude folders", path) << endl; | 345 | out << i18n("%1 is in the list of exclude folders", path) << endl; | ||
345 | out << "Aborting" << endl; | 346 | out << "Aborting" << endl; | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |