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++;
|
newItems++;
|
||||||
if (firstItemNew.isEmpty())
|
if (firstItemNew.isEmpty())
|
||||||
firstItemNew = item;
|
firstItemNew = item;
|
||||||
|
|
||||||
|
if (item._type == SyncFileItem::Directory) {
|
||||||
|
_watcher->addPath(path() + item._file);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CSYNC_INSTRUCTION_REMOVE:
|
case CSYNC_INSTRUCTION_REMOVE:
|
||||||
removedItems++;
|
removedItems++;
|
||||||
if (firstItemDeleted.isEmpty())
|
if (firstItemDeleted.isEmpty())
|
||||||
firstItemDeleted = item;
|
firstItemDeleted = item;
|
||||||
|
|
||||||
|
if (item._type == SyncFileItem::Directory) {
|
||||||
|
_watcher->removePath(path() + item._file);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CSYNC_INSTRUCTION_UPDATED:
|
case CSYNC_INSTRUCTION_UPDATED:
|
||||||
updatedItems++;
|
updatedItems++;
|
||||||
|
|
|
@ -172,5 +172,16 @@ void FolderWatcher::changeDetected(const QString& f)
|
||||||
setProcessTimer();
|
setProcessTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FolderWatcher::addPath(const QString &path )
|
||||||
|
{
|
||||||
|
_d->addPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FolderWatcher::removePath(const QString &path )
|
||||||
|
{
|
||||||
|
_d->removePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Mirall
|
} // namespace Mirall
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,15 @@ public:
|
||||||
void setEventInterval(int seconds);
|
void setEventInterval(int seconds);
|
||||||
|
|
||||||
QStringList ignores() const;
|
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:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* Enabled or disables folderChanged() events.
|
* Enabled or disables folderChanged() events.
|
||||||
|
|
|
@ -119,9 +119,8 @@ void FolderWatcherPrivate::slotINotifyEvent(int mask, int /*cookie*/, const QStr
|
||||||
}
|
}
|
||||||
else if (mask & IN_DELETE) {
|
else if (mask & IN_DELETE) {
|
||||||
//qDebug() << cookie << " DELETE: " << path;
|
//qDebug() << cookie << " DELETE: " << path;
|
||||||
if ( QFileInfo(path).isDir() && _inotify->directories().contains(path) ) {
|
if ( QFileInfo(path).isDir() ) {
|
||||||
qDebug() << "(-) Watcher:" << path;
|
removePath(path);
|
||||||
_inotify->removePath(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mask & IN_CLOSE_WRITE) {
|
else if (mask & IN_CLOSE_WRITE) {
|
||||||
|
@ -160,4 +159,13 @@ void FolderWatcherPrivate::slotINotifyEvent(int mask, int /*cookie*/, const QStr
|
||||||
_parent->setProcessTimer();
|
_parent->setProcessTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FolderWatcherPrivate::removePath(const QString &path )
|
||||||
|
{
|
||||||
|
if (_inotify->directories().contains(path) ) {
|
||||||
|
qDebug() << "(-) Watcher:" << path;
|
||||||
|
_inotify->removePath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Mirall
|
} // namespace Mirall
|
||||||
|
|
|
@ -26,6 +26,8 @@ class FolderWatcherPrivate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FolderWatcherPrivate(FolderWatcher *p);
|
FolderWatcherPrivate(FolderWatcher *p);
|
||||||
|
void addPath(const QString &path) { slotAddFolderRecursive(path); }
|
||||||
|
void removePath(const QString &);
|
||||||
signals:
|
signals:
|
||||||
void error(const QString& error);
|
void error(const QString& error);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -31,6 +31,9 @@ public:
|
||||||
FolderWatcherPrivate(FolderWatcher *p);
|
FolderWatcherPrivate(FolderWatcher *p);
|
||||||
~FolderWatcherPrivate();
|
~FolderWatcherPrivate();
|
||||||
|
|
||||||
|
void addPath(const QString &) {}
|
||||||
|
void removePath(const QString &) {}
|
||||||
|
|
||||||
void startWatching();
|
void startWatching();
|
||||||
void doNotifyParent();
|
void doNotifyParent();
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,10 @@ class FolderWatcherPrivate : public QObject {
|
||||||
public:
|
public:
|
||||||
FolderWatcherPrivate(FolderWatcher *p);
|
FolderWatcherPrivate(FolderWatcher *p);
|
||||||
~FolderWatcherPrivate();
|
~FolderWatcherPrivate();
|
||||||
|
|
||||||
|
void addPath(const QString &) {}
|
||||||
|
void removePath(const QString &) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FolderWatcher *_parent;
|
FolderWatcher *_parent;
|
||||||
WatcherThread *_thread;
|
WatcherThread *_thread;
|
||||||
|
|
Loading…
Reference in a new issue