mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
Add the new directories comming from the sync in the watcher
This commit is contained in:
parent
a19a960b5e
commit
b4c116e2a2
7 changed files with 50 additions and 3 deletions
|
@ -297,11 +297,21 @@ void Folder::bubbleUpSyncResult()
|
|||
newItems++;
|
||||
if (firstItemNew.isEmpty())
|
||||
firstItemNew = item;
|
||||
|
||||
if (item._type == SyncFileItem::Directory) {
|
||||
_watcher->addPath(path() + item._file);
|
||||
}
|
||||
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_REMOVE:
|
||||
removedItems++;
|
||||
if (firstItemDeleted.isEmpty())
|
||||
firstItemDeleted = item;
|
||||
|
||||
if (item._type == SyncFileItem::Directory) {
|
||||
_watcher->removePath(path() + item._file);
|
||||
}
|
||||
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_UPDATED:
|
||||
updatedItems++;
|
||||
|
|
|
@ -172,5 +172,16 @@ void FolderWatcher::changeDetected(const QString& f)
|
|||
setProcessTimer();
|
||||
}
|
||||
|
||||
void FolderWatcher::addPath(const QString &path )
|
||||
{
|
||||
_d->addPath(path);
|
||||
}
|
||||
|
||||
void FolderWatcher::removePath(const QString &path )
|
||||
{
|
||||
_d->removePath(path);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Mirall
|
||||
|
||||
|
|
|
@ -88,6 +88,15 @@ public:
|
|||
void setEventInterval(int seconds);
|
||||
|
||||
QStringList ignores() const;
|
||||
|
||||
/**
|
||||
* Not all backends are recursive by default.
|
||||
* Those need to be notified when a directory is added or removed while the watcher is disabled.
|
||||
* This is a no-op for backend that are recursive
|
||||
*/
|
||||
void addPath(const QString&);
|
||||
void removePath(const QString&);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Enabled or disables folderChanged() events.
|
||||
|
|
|
@ -119,9 +119,8 @@ void FolderWatcherPrivate::slotINotifyEvent(int mask, int /*cookie*/, const QStr
|
|||
}
|
||||
else if (mask & IN_DELETE) {
|
||||
//qDebug() << cookie << " DELETE: " << path;
|
||||
if ( QFileInfo(path).isDir() && _inotify->directories().contains(path) ) {
|
||||
qDebug() << "(-) Watcher:" << path;
|
||||
_inotify->removePath(path);
|
||||
if ( QFileInfo(path).isDir() ) {
|
||||
removePath(path);
|
||||
}
|
||||
}
|
||||
else if (mask & IN_CLOSE_WRITE) {
|
||||
|
@ -160,4 +159,13 @@ void FolderWatcherPrivate::slotINotifyEvent(int mask, int /*cookie*/, const QStr
|
|||
_parent->setProcessTimer();
|
||||
}
|
||||
|
||||
void FolderWatcherPrivate::removePath(const QString &path )
|
||||
{
|
||||
if (_inotify->directories().contains(path) ) {
|
||||
qDebug() << "(-) Watcher:" << path;
|
||||
_inotify->removePath(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Mirall
|
||||
|
|
|
@ -26,6 +26,8 @@ class FolderWatcherPrivate : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
FolderWatcherPrivate(FolderWatcher *p);
|
||||
void addPath(const QString &path) { slotAddFolderRecursive(path); }
|
||||
void removePath(const QString &);
|
||||
signals:
|
||||
void error(const QString& error);
|
||||
private slots:
|
||||
|
|
|
@ -31,6 +31,9 @@ public:
|
|||
FolderWatcherPrivate(FolderWatcher *p);
|
||||
~FolderWatcherPrivate();
|
||||
|
||||
void addPath(const QString &) {}
|
||||
void removePath(const QString &) {}
|
||||
|
||||
void startWatching();
|
||||
void doNotifyParent();
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ class FolderWatcherPrivate : public QObject {
|
|||
public:
|
||||
FolderWatcherPrivate(FolderWatcher *p);
|
||||
~FolderWatcherPrivate();
|
||||
|
||||
void addPath(const QString &) {}
|
||||
void removePath(const QString &) {}
|
||||
|
||||
private:
|
||||
FolderWatcher *_parent;
|
||||
WatcherThread *_thread;
|
||||
|
|
Loading…
Reference in a new issue