Skip to content

Commit f1cea38

Browse files
committed
Include recent change events in local discover
Since 5.0 we accumulate changes for 10s, include accumulated changes when starting a sync.
1 parent 09a87a9 commit f1cea38

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

changelog/unreleased/11347

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: Include recent changes in scheduled syncs
2+
3+
When starting a new sync we now also include the recent change events in the discovery.
4+
5+
https://github.com/owncloud/client/pull/11347

src/gui/folder.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,10 @@ void Folder::startSync()
963963

964964
setDirtyNetworkLimits();
965965

966+
// get the latest touched files
967+
// this will enque this folder again, it doesn't matter
968+
slotWatchedPathsChanged(_folderWatcher->popChangeSet(), Folder::ChangeReason::Other);
969+
966970
const std::chrono::milliseconds fullLocalDiscoveryInterval = ConfigFile().fullLocalDiscoveryInterval();
967971
const bool hasDoneFullLocalDiscovery = _timeSinceLastFullLocalDiscovery.isValid();
968972
// negative fullLocalDiscoveryInterval means we don't require periodic full runs

src/gui/folderwatcher.cpp

+20-14
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,7 @@ FolderWatcher::FolderWatcher(Folder *folder)
5050
{
5151
_timer.setInterval(notificationTimeoutC);
5252
connect(&_timer, &QTimer::timeout, this, [this] {
53-
auto paths = std::move(_changeSet);
54-
// ------- handle ignores:
55-
auto it = paths.cbegin();
56-
while (it != paths.cend()) {
57-
// we cause a file change from time to time to check whether the folder watcher works as expected
58-
if (!_testNotificationPath.isEmpty() && Utility::fileNamesEqual(*it, _testNotificationPath)) {
59-
_testNotificationPath.clear();
60-
}
61-
if (pathIsIgnored(*it)) {
62-
it = paths.erase(it);
63-
} else {
64-
++it;
65-
}
66-
}
53+
auto paths = popChangeSet();
6754
if (!paths.isEmpty()) {
6855
qCInfo(lcFolderWatcher) << "Detected changes in paths:" << paths;
6956
emit pathChanged(paths);
@@ -160,4 +147,23 @@ void FolderWatcher::changeDetected(const QSet<QString> &paths)
160147
}
161148
}
162149

150+
QSet<QString> FolderWatcher::popChangeSet()
151+
{
152+
auto paths = std::move(_changeSet);
153+
// ------- handle ignores:
154+
auto it = paths.cbegin();
155+
while (it != paths.cend()) {
156+
// we cause a file change from time to time to check whether the folder watcher works as expected
157+
if (!_testNotificationPath.isEmpty() && Utility::fileNamesEqual(*it, _testNotificationPath)) {
158+
_testNotificationPath.clear();
159+
}
160+
if (pathIsIgnored(*it)) {
161+
it = paths.erase(it);
162+
} else {
163+
++it;
164+
}
165+
}
166+
return paths;
167+
}
168+
163169
} // namespace OCC

src/gui/folderwatcher.h

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class FolderWatcher : public QObject
8080
/// For testing linux behavior only
8181
int testLinuxWatchCount() const;
8282

83+
// pop the accumulated changes
84+
QSet<QString> popChangeSet();
85+
86+
8387
signals:
8488
/** Emitted when one of the watched directories or one
8589
* of the contained files is changed. */

0 commit comments

Comments
 (0)