diff options
author | Christian Kamm <mail@ckamm.de> | 2017-10-09 13:06:57 +0300 |
---|---|---|
committer | ckamm <mail@ckamm.de> | 2017-10-24 11:00:20 +0300 |
commit | 66f0ce6616edcb6e44d235ae779170eb28c9c7c0 (patch) | |
tree | d3163e0d4e2adffd37c05f9a1d293a06c0a4b439 /src/gui/folderwatcher.h | |
parent | fb2d31c9cedd10bc3b0cee7ccfff0756f6615386 (diff) |
FolderWatcher: reliability and data-loss signal
Add state and signal to catch the following two known problems:
* Linux: inotify user watch pool is exhausted. Folder watcher becomes
unreliable.
* Windows: buffer is too small, some notifications are lost but watching
stays reliable.
Diffstat (limited to 'src/gui/folderwatcher.h')
-rw-r--r-- | src/gui/folderwatcher.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gui/folderwatcher.h b/src/gui/folderwatcher.h index 334abf1b7..ac40a2ea3 100644 --- a/src/gui/folderwatcher.h +++ b/src/gui/folderwatcher.h @@ -72,13 +72,29 @@ public: /* Check if the path is ignored. */ bool pathIsIgnored(const QString &path); + /** + * Returns false if the folder watcher can't be trusted to capture all + * notifications. + * + * For example, this can happen on linux if the inotify user limit from + * /proc/sys/fs/inotify/max_user_watches is exceeded. + */ + bool isReliable() const; + signals: /** Emitted when one of the watched directories or one * of the contained files is changed. */ void pathChanged(const QString &path); - /** Emitted if an error occurs */ - void error(const QString &error); + /** + * Emitted if some notifications were lost. + * + * Would happen, for example, if the number of pending notifications + * exceeded the allocated buffer size on Windows. Note that the folder + * watcher could still be able to capture all future notifications - + * i.e. isReliable() is orthogonal to losing changes occasionally. + */ + void lostChanges(); protected slots: // called from the implementations to indicate a change in path @@ -93,6 +109,7 @@ private: QTime _timer; QSet<QString> _lastPaths; Folder *_folder; + bool _isReliable = true; friend class FolderWatcherPrivate; }; |