Merge pull request #2439 from nextcloud/fix-subfolder-missing-contentsync

Fix missing subdirectory discovery on move operations in macOS
This commit is contained in:
Dominique Fuchs 2020-09-17 16:04:12 +02:00 committed by GitHub
commit 54364e7374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

23
src/gui/folderwatcher_mac.cpp Normal file → Executable file
View File

@ -19,6 +19,7 @@
#include <cerrno>
#include <QDirIterator>
#include <QStringList>
@ -90,8 +91,6 @@ void FolderWatcherPrivate::startWatching()
FSEventStreamContext ctx = { 0, this, nullptr, nullptr, nullptr };
// TODO: Add kFSEventStreamCreateFlagFileEvents ?
_stream = FSEventStreamCreate(nullptr,
&callback,
&ctx,
@ -105,9 +104,27 @@ void FolderWatcherPrivate::startWatching()
FSEventStreamStart(_stream);
}
QStringList FolderWatcherPrivate::addCoalescedPaths(const QStringList &paths) const
{
QStringList coalescedPaths;
for (const auto &eventPath : paths) {
if (QDir(eventPath).exists()) {
QDirIterator it(eventPath, QDir::AllDirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (it.hasNext()) {
auto subfolder = it.next();
if (!paths.contains(subfolder)) {
coalescedPaths.append(subfolder);
}
}
}
}
return (paths + coalescedPaths);
}
void FolderWatcherPrivate::doNotifyParent(const QStringList &paths)
{
_parent->changeDetected(paths);
const QStringList totalPaths = addCoalescedPaths(paths);
_parent->changeDetected(totalPaths);
}

1
src/gui/folderwatcher_mac.h Normal file → Executable file
View File

@ -37,6 +37,7 @@ public:
void removePath(const QString &) {}
void startWatching();
QStringList addCoalescedPaths(const QStringList &) const;
void doNotifyParent(const QStringList &);
private: