mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 21:46:03 +03:00
Notify user if there is a problem with the inotify watcher
This commit is contained in:
parent
9b319cf189
commit
c24d6bd71c
7 changed files with 25 additions and 9 deletions
|
@ -302,6 +302,11 @@ void Folder::slotThreadTreeWalkResult(const SyncFileItemVector& items)
|
||||||
_syncResult.setSyncFileItemVector(items);
|
_syncResult.setSyncFileItemVector(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Folder::slotCatchWatcherError(const QString& error)
|
||||||
|
{
|
||||||
|
Logger::instance()->postGuiLog(tr("Error"), error);
|
||||||
|
}
|
||||||
|
|
||||||
void Folder::slotTerminateSync()
|
void Folder::slotTerminateSync()
|
||||||
{
|
{
|
||||||
qDebug() << "folder " << alias() << " Terminating!";
|
qDebug() << "folder " << alias() << " Terminating!";
|
||||||
|
|
|
@ -177,6 +177,7 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void slotLocalPathChanged( const QString& );
|
void slotLocalPathChanged( const QString& );
|
||||||
void slotThreadTreeWalkResult(const SyncFileItemVector& );
|
void slotThreadTreeWalkResult(const SyncFileItemVector& );
|
||||||
|
void slotCatchWatcherError( const QString& );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool init();
|
bool init();
|
||||||
|
|
|
@ -43,7 +43,7 @@ class FolderWatcherPrivate;
|
||||||
*/
|
*/
|
||||||
class FolderWatcher : public QObject
|
class FolderWatcher : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @param root Path of the root of the folder
|
* @param root Path of the root of the folder
|
||||||
|
@ -104,10 +104,10 @@ public slots:
|
||||||
void setEventsEnabledDelayed( int );
|
void setEventsEnabledDelayed( int );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/** Emitted when one of the paths is changed */
|
||||||
* Emitted when one of the paths is changed
|
|
||||||
*/
|
|
||||||
void folderChanged(const QStringList &pathList);
|
void folderChanged(const QStringList &pathList);
|
||||||
|
/** Emitted if an error occurs */
|
||||||
|
void error(const QString& error);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setProcessTimer();
|
void setProcessTimer();
|
||||||
|
|
|
@ -49,7 +49,12 @@ void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
|
||||||
int subdirs = 0;
|
int subdirs = 0;
|
||||||
qDebug() << "(+) Watcher:" << path;
|
qDebug() << "(+) Watcher:" << path;
|
||||||
|
|
||||||
_inotify->addPath(path);
|
if (!_inotify->addPath(path)) {
|
||||||
|
FolderWatcher *fw = qobject_cast<FolderWatcher*>(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());
|
QStringList watchedFolders(_inotify->directories());
|
||||||
// qDebug() << "currently watching " << watchedFolders;
|
// qDebug() << "currently watching " << watchedFolders;
|
||||||
QStringListIterator subfoldersIt(FileUtils::subFoldersList(path, FileUtils::SubFolderRecursive));
|
QStringListIterator subfoldersIt(FileUtils::subFoldersList(path, FileUtils::SubFolderRecursive));
|
||||||
|
|
|
@ -26,6 +26,8 @@ class FolderWatcherPrivate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FolderWatcherPrivate(FolderWatcher *p);
|
FolderWatcherPrivate(FolderWatcher *p);
|
||||||
|
signals:
|
||||||
|
void error(const QString& error);
|
||||||
private slots:
|
private slots:
|
||||||
void slotAddFolderRecursive(const QString &path);
|
void slotAddFolderRecursive(const QString &path);
|
||||||
void slotINotifyEvent(int mask, int cookie, const QString &path);
|
void slotINotifyEvent(int mask, int cookie, const QString &path);
|
||||||
|
|
|
@ -115,14 +115,17 @@ INotify::~INotify()
|
||||||
delete _notifier;
|
delete _notifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotify::addPath(const QString &path)
|
bool INotify::addPath(const QString &path)
|
||||||
{
|
{
|
||||||
// Add an inotify watch.
|
// Add an inotify watch.
|
||||||
int wd = inotify_add_watch(_fd, path.toUtf8().constData(), _mask);
|
int wd = inotify_add_watch(_fd, path.toUtf8().constData(), _mask);
|
||||||
if( wd > -1 )
|
if( wd > -1 ) {
|
||||||
_wds[path] = wd;
|
_wds[path] = wd;
|
||||||
else
|
return true;
|
||||||
|
} else {
|
||||||
qDebug() << "WRN: Could not watch " << path << ':' << strerror(errno);
|
qDebug() << "WRN: Could not watch " << path << ':' << strerror(errno);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotify::removePath(const QString &path)
|
void INotify::removePath(const QString &path)
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
INotify(QObject *parent, int mask);
|
INotify(QObject *parent, int mask);
|
||||||
~INotify();
|
~INotify();
|
||||||
|
|
||||||
void addPath(const QString &name);
|
bool addPath(const QString &name);
|
||||||
void removePath(const QString &name);
|
void removePath(const QString &name);
|
||||||
|
|
||||||
QStringList directories() const;
|
QStringList directories() const;
|
||||||
|
|
Loading…
Reference in a new issue