diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index 79569db8a..8b82b664e 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -302,6 +302,11 @@ void Folder::slotThreadTreeWalkResult(const SyncFileItemVector& items) _syncResult.setSyncFileItemVector(items); } +void Folder::slotCatchWatcherError(const QString& error) +{ + Logger::instance()->postGuiLog(tr("Error"), error); +} + void Folder::slotTerminateSync() { qDebug() << "folder " << alias() << " Terminating!"; diff --git a/src/mirall/folder.h b/src/mirall/folder.h index b77e95659..44fea9b5a 100644 --- a/src/mirall/folder.h +++ b/src/mirall/folder.h @@ -177,6 +177,7 @@ private slots: */ void slotLocalPathChanged( const QString& ); void slotThreadTreeWalkResult(const SyncFileItemVector& ); + void slotCatchWatcherError( const QString& ); protected: bool init(); diff --git a/src/mirall/folderwatcher.h b/src/mirall/folderwatcher.h index 2cdf28a8c..23903ea13 100644 --- a/src/mirall/folderwatcher.h +++ b/src/mirall/folderwatcher.h @@ -43,7 +43,7 @@ class FolderWatcherPrivate; */ class FolderWatcher : public QObject { -Q_OBJECT + Q_OBJECT public: /** * @param root Path of the root of the folder @@ -104,10 +104,10 @@ public slots: void setEventsEnabledDelayed( int ); signals: - /** - * Emitted when one of the paths is changed - */ + /** Emitted when one of the paths is changed */ void folderChanged(const QStringList &pathList); + /** Emitted if an error occurs */ + void error(const QString& error); protected: void setProcessTimer(); diff --git a/src/mirall/folderwatcher_inotify.cpp b/src/mirall/folderwatcher_inotify.cpp index 4257efb36..47f501b97 100644 --- a/src/mirall/folderwatcher_inotify.cpp +++ b/src/mirall/folderwatcher_inotify.cpp @@ -49,7 +49,12 @@ void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path) int subdirs = 0; qDebug() << "(+) Watcher:" << path; - _inotify->addPath(path); + if (!_inotify->addPath(path)) { + FolderWatcher *fw = qobject_cast(parent()); + emit fw->error(tr("Could not monitor directories due to system limitations.\n" + "The application will not work reliably. Please check the\n" + "documentation for possible fixes.")); + } QStringList watchedFolders(_inotify->directories()); // qDebug() << "currently watching " << watchedFolders; QStringListIterator subfoldersIt(FileUtils::subFoldersList(path, FileUtils::SubFolderRecursive)); diff --git a/src/mirall/folderwatcher_inotify.h b/src/mirall/folderwatcher_inotify.h index 6cc415dbb..67954958a 100644 --- a/src/mirall/folderwatcher_inotify.h +++ b/src/mirall/folderwatcher_inotify.h @@ -26,6 +26,8 @@ class FolderWatcherPrivate : public QObject { Q_OBJECT public: FolderWatcherPrivate(FolderWatcher *p); +signals: + void error(const QString& error); private slots: void slotAddFolderRecursive(const QString &path); void slotINotifyEvent(int mask, int cookie, const QString &path); diff --git a/src/mirall/inotify.cpp b/src/mirall/inotify.cpp index 126a1d57e..60bda41be 100644 --- a/src/mirall/inotify.cpp +++ b/src/mirall/inotify.cpp @@ -115,14 +115,17 @@ INotify::~INotify() delete _notifier; } -void INotify::addPath(const QString &path) +bool INotify::addPath(const QString &path) { // Add an inotify watch. int wd = inotify_add_watch(_fd, path.toUtf8().constData(), _mask); - if( wd > -1 ) + if( wd > -1 ) { _wds[path] = wd; - else + return true; + } else { qDebug() << "WRN: Could not watch " << path << ':' << strerror(errno); + return false; + } } void INotify::removePath(const QString &path) diff --git a/src/mirall/inotify.h b/src/mirall/inotify.h index eefc76f54..8a08bd018 100644 --- a/src/mirall/inotify.h +++ b/src/mirall/inotify.h @@ -38,7 +38,7 @@ public: INotify(QObject *parent, int mask); ~INotify(); - void addPath(const QString &name); + bool addPath(const QString &name); void removePath(const QString &name); QStringList directories() const;