INotify backend: honor ignored files

Actually this needs a careful redesign,
but this is good enough to fix the issue.

Fixes: #763
This commit is contained in:
Daniel Molkentin 2013-07-22 21:39:13 +02:00
parent 56e5627b6b
commit 8236dafb96
3 changed files with 7 additions and 18 deletions

View file

@ -79,18 +79,12 @@ void FolderWatcher::addIgnoreListFile( const QString& file )
while (!infile.atEnd()) { while (!infile.atEnd()) {
QString line = QString::fromLocal8Bit( infile.readLine() ).trimmed(); QString line = QString::fromLocal8Bit( infile.readLine() ).trimmed();
if( !line.startsWith( QLatin1Char('#') )) { if( !line.startsWith( QLatin1Char('#') ) && line.isEmpty() ) {
addIgnore(line); _ignores.append(line);
} }
} }
} }
void FolderWatcher::addIgnore(const QString &pattern)
{
if( pattern.isEmpty() ) return;
_ignores.append(pattern);
}
QStringList FolderWatcher::ignores() const QStringList FolderWatcher::ignores() const
{ {
return _ignores; return _ignores;

View file

@ -58,17 +58,12 @@ public:
/** /**
* Set a file name to load a file with ignore patterns. * Set a file name to load a file with ignore patterns.
*
* Valid entries do not start with a hash sign (#)
* and may contain wildcards
*/ */
void addIgnoreListFile( const QString& ); void addIgnoreListFile( const QString& );
/**
* Add an ignore pattern that will not be
* notified
*
* You can use wildcards
*/
void addIgnore(const QString &pattern);
/** /**
* If true, folderChanged() events are sent * If true, folderChanged() events are sent
* at least as often as eventInterval() seconds. * at least as often as eventInterval() seconds.

View file

@ -38,10 +38,10 @@ FolderWatcherPrivate::FolderWatcherPrivate(FolderWatcher *p)
{ {
_inotify = new INotify(this, standard_event_mask); _inotify = new INotify(this, standard_event_mask);
slotAddFolderRecursive(_parent->root());
QObject::connect(_inotify, SIGNAL(notifyEvent(int, int, const QString &)), QObject::connect(_inotify, SIGNAL(notifyEvent(int, int, const QString &)),
this, SLOT(slotINotifyEvent(int, int, const QString &))); this, SLOT(slotINotifyEvent(int, int, const QString &)));
QMetaObject::invokeMethod(this, "slotAddFolderRecursive", Q_ARG(QString, _parent->root()));
} }
void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path) void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
@ -131,7 +131,7 @@ void FolderWatcherPrivate::slotINotifyEvent(int mask, int cookie, const QString
foreach (const QString& pattern, _parent->ignores()) { foreach (const QString& pattern, _parent->ignores()) {
QRegExp regexp(pattern); QRegExp regexp(pattern);
regexp.setPatternSyntax(QRegExp::Wildcard); regexp.exactMatch(QRegExp::Wildcard);
if (regexp.exactMatch(path)) { if (regexp.exactMatch(path)) {
qDebug() << "* Discarded by ignore pattern: " << path; qDebug() << "* Discarded by ignore pattern: " << path;