Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kamm <mail@ckamm.de>2018-10-12 12:03:10 +0300
committerckamm <mail@ckamm.de>2018-10-12 13:06:48 +0300
commit55cf407337a5db93511f1cb061165c53fa6dba6e (patch)
tree9cc826d82cf598c7923e2ba16a938d2b10dbade8 /src/gui/folderwatcher_linux.h
parentd0815239807540c423c52282e57a5ed8ebfd41e2 (diff)
Folderwatcher: On linux, fix paths after dir renames #6808
If a folder was renamed A -> B, the folder watcher for the inode would be unaware and still report changes for A/foo. Now directory renames in the watched folders are tracked and paths are updated accordingly.
Diffstat (limited to 'src/gui/folderwatcher_linux.h')
-rw-r--r--src/gui/folderwatcher_linux.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/folderwatcher_linux.h b/src/gui/folderwatcher_linux.h
index 24d337777..e9361eb42 100644
--- a/src/gui/folderwatcher_linux.h
+++ b/src/gui/folderwatcher_linux.h
@@ -23,6 +23,8 @@
#include "folderwatcher.h"
+class QTimer;
+
namespace OCC {
/**
@@ -44,10 +46,22 @@ protected slots:
void slotReceivedNotification(int fd);
void slotAddFolderRecursive(const QString &path);
+ /// Remove all half-built renames. Called by timer when idle for a bit.
+ void wipePotentialRenames();
+
protected:
+ struct Rename
+ {
+ QString from;
+ QString to;
+ };
+
bool findFoldersBelow(const QDir &dir, QStringList &fullList);
void inotifyRegisterPath(const QString &path);
+ /// Adjusts the paths in _watches when directories are renamed.
+ void applyDirectoryRename(const Rename &rename);
+
private:
FolderWatcher *_parent;
@@ -55,6 +69,25 @@ private:
QHash<int, QString> _watches;
QScopedPointer<QSocketNotifier> _socket;
int _fd;
+
+ /** Maps inotify event cookie to rename data.
+ *
+ * For moves two independent inotify events will be seen and they
+ * can be matched via the event cookie. This field stores partial
+ * information as it is received. When both sides have arrived,
+ * directory moves can be processed with applyDirectoryRename().
+ *
+ * If we don't receive both sides (if something moves away from
+ * the watched folder tree, or into it from an unwatched location)
+ * the _wipePotentialRenamesSoon will eventually discard the
+ * incomplete data.
+ *
+ * These events can even be emitted by different watches if the
+ * directory parent folder changed.
+ */
+ QHash<quint32, Rename> _potentialRenames;
+
+ QTimer *_wipePotentialRenamesSoon;
};
}