diff --git a/changelog/unreleased/11347 b/changelog/unreleased/11347 new file mode 100644 index 00000000000..a58729274cf --- /dev/null +++ b/changelog/unreleased/11347 @@ -0,0 +1,5 @@ +Enhancement: Include recent changes in scheduled syncs + +When starting a new sync we now also include the recent change events in the discovery. + +https://github.com/owncloud/client/pull/11347 diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 2437449e4d9..0cf1201ccc8 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -956,6 +956,10 @@ void Folder::startSync() setDirtyNetworkLimits(); + // get the latest touched files + // this will enque this folder again, it doesn't matter + slotWatchedPathsChanged(_folderWatcher->popChangeSet(), Folder::ChangeReason::Other); + const std::chrono::milliseconds fullLocalDiscoveryInterval = ConfigFile().fullLocalDiscoveryInterval(); const bool hasDoneFullLocalDiscovery = _timeSinceLastFullLocalDiscovery.isValid(); // negative fullLocalDiscoveryInterval means we don't require periodic full runs diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp index 1496529c482..eb6b82a005f 100644 --- a/src/gui/folderwatcher.cpp +++ b/src/gui/folderwatcher.cpp @@ -50,20 +50,7 @@ FolderWatcher::FolderWatcher(Folder *folder) { _timer.setInterval(notificationTimeoutC); connect(&_timer, &QTimer::timeout, this, [this] { - auto paths = std::move(_changeSet); - // ------- handle ignores: - auto it = paths.cbegin(); - while (it != paths.cend()) { - // we cause a file change from time to time to check whether the folder watcher works as expected - if (!_testNotificationPath.isEmpty() && Utility::fileNamesEqual(*it, _testNotificationPath)) { - _testNotificationPath.clear(); - } - if (pathIsIgnored(*it)) { - it = paths.erase(it); - } else { - ++it; - } - } + auto paths = popChangeSet(); if (!paths.isEmpty()) { qCInfo(lcFolderWatcher) << "Detected changes in paths:" << paths; emit pathChanged(paths); @@ -160,4 +147,23 @@ void FolderWatcher::changeDetected(const QSet &paths) } } +QSet FolderWatcher::popChangeSet() +{ + auto paths = std::move(_changeSet); + // ------- handle ignores: + auto it = paths.cbegin(); + while (it != paths.cend()) { + // we cause a file change from time to time to check whether the folder watcher works as expected + if (!_testNotificationPath.isEmpty() && Utility::fileNamesEqual(*it, _testNotificationPath)) { + _testNotificationPath.clear(); + } + if (pathIsIgnored(*it)) { + it = paths.erase(it); + } else { + ++it; + } + } + return paths; +} + } // namespace OCC diff --git a/src/gui/folderwatcher.h b/src/gui/folderwatcher.h index 31b68b61812..79c70a3291c 100644 --- a/src/gui/folderwatcher.h +++ b/src/gui/folderwatcher.h @@ -80,6 +80,10 @@ class FolderWatcher : public QObject /// For testing linux behavior only int testLinuxWatchCount() const; + // pop the accumulated changes + QSet popChangeSet(); + + signals: /** Emitted when one of the watched directories or one * of the contained files is changed. */