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:
authorMarkus Goetz <markus@woboq.com>2016-06-02 19:12:47 +0300
committerMarkus Goetz <markus@woboq.com>2016-06-02 19:20:07 +0300
commit51f8a59a9a16fa9fe02b83f82447a93e5719575e (patch)
tree7751629b60292c13609c278dc821809b0c65930d /src/gui/folderwatcher_mac.cpp
parentebbe5acf2ba0f8a7822a5a1fb25aa446b28f5186 (diff)
OS X: White-list the folder watcher enums
I got syncs triggered for even opening a file by double clicking it in Finder and having launched Preview.app (e.g. for JPEG files).
Diffstat (limited to 'src/gui/folderwatcher_mac.cpp')
-rw-r--r--src/gui/folderwatcher_mac.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/folderwatcher_mac.cpp b/src/gui/folderwatcher_mac.cpp
index ada7f1064..be4260842 100644
--- a/src/gui/folderwatcher_mac.cpp
+++ b/src/gui/folderwatcher_mac.cpp
@@ -51,6 +51,14 @@ static void callback(
Q_UNUSED(eventFlags)
Q_UNUSED(eventIds)
+ const FSEventStreamEventFlags c_interestingFlags
+ = kFSEventStreamEventFlagItemCreated // for new folder/file
+ | kFSEventStreamEventFlagItemRemoved // for rm
+ | kFSEventStreamEventFlagItemInodeMetaMod // for mtime change
+ | kFSEventStreamEventFlagItemRenamed // also coming for moves to trash in finder
+ | kFSEventStreamEventFlagItemModified; // for content change
+ //We ignore other flags, e.g. for owner change, xattr change, Finder label change etc
+
qDebug() << "FolderWatcherPrivate::callback by OS X";
QStringList paths;
@@ -62,8 +70,14 @@ static void callback(
CFIndex pathLength = CFStringGetLength(path);
qstring.resize(pathLength);
CFStringGetCharacters(path, CFRangeMake(0, pathLength), reinterpret_cast<UniChar *>(qstring.data()));
+ QString fn = qstring.normalized(QString::NormalizationForm_C);
+
+ if (!(eventFlags[i] & c_interestingFlags)) {
+ qDebug() << "Ignoring non-content changes for" << fn;
+ continue;
+ }
- paths.append(qstring.normalized(QString::NormalizationForm_C));
+ paths.append(fn);
}
reinterpret_cast<FolderWatcherPrivate*>(clientCallBackInfo)->doNotifyParent(paths);