From 8236dafb96b211d37bf399bf7352bac2ddeb151c Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 22 Jul 2013 21:39:13 +0200 Subject: [PATCH] INotify backend: honor ignored files Actually this needs a careful redesign, but this is good enough to fix the issue. Fixes: #763 --- src/mirall/folderwatcher.cpp | 10 ++-------- src/mirall/folderwatcher.h | 11 +++-------- src/mirall/folderwatcher_inotify.cpp | 4 ++-- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/mirall/folderwatcher.cpp b/src/mirall/folderwatcher.cpp index b038ff5b81..01e51cbe68 100644 --- a/src/mirall/folderwatcher.cpp +++ b/src/mirall/folderwatcher.cpp @@ -79,18 +79,12 @@ void FolderWatcher::addIgnoreListFile( const QString& file ) while (!infile.atEnd()) { QString line = QString::fromLocal8Bit( infile.readLine() ).trimmed(); - if( !line.startsWith( QLatin1Char('#') )) { - addIgnore(line); + if( !line.startsWith( QLatin1Char('#') ) && line.isEmpty() ) { + _ignores.append(line); } } } -void FolderWatcher::addIgnore(const QString &pattern) -{ - if( pattern.isEmpty() ) return; - _ignores.append(pattern); -} - QStringList FolderWatcher::ignores() const { return _ignores; diff --git a/src/mirall/folderwatcher.h b/src/mirall/folderwatcher.h index e04fe06881..2cdf28a8cc 100644 --- a/src/mirall/folderwatcher.h +++ b/src/mirall/folderwatcher.h @@ -58,17 +58,12 @@ public: /** * 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& ); - /** - * Add an ignore pattern that will not be - * notified - * - * You can use wildcards - */ - void addIgnore(const QString &pattern); - /** * If true, folderChanged() events are sent * at least as often as eventInterval() seconds. diff --git a/src/mirall/folderwatcher_inotify.cpp b/src/mirall/folderwatcher_inotify.cpp index 1451d8ba49..feda818ef1 100644 --- a/src/mirall/folderwatcher_inotify.cpp +++ b/src/mirall/folderwatcher_inotify.cpp @@ -38,10 +38,10 @@ FolderWatcherPrivate::FolderWatcherPrivate(FolderWatcher *p) { _inotify = new INotify(this, standard_event_mask); - slotAddFolderRecursive(_parent->root()); QObject::connect(_inotify, SIGNAL(notifyEvent(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) @@ -131,7 +131,7 @@ void FolderWatcherPrivate::slotINotifyEvent(int mask, int cookie, const QString foreach (const QString& pattern, _parent->ignores()) { QRegExp regexp(pattern); - regexp.setPatternSyntax(QRegExp::Wildcard); + regexp.exactMatch(QRegExp::Wildcard); if (regexp.exactMatch(path)) { qDebug() << "* Discarded by ignore pattern: " << path;