mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
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:
parent
56e5627b6b
commit
8236dafb96
3 changed files with 7 additions and 18 deletions
|
@ -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;
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue