Skip to content

Commit

Permalink
Include recent change events in local discover
Browse files Browse the repository at this point in the history
Since 5.0 we accumulate changes for 10s, include accumulated changes when starting a sync.
  • Loading branch information
TheOneRing committed Nov 16, 2023
1 parent de2533d commit ac13bd5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/11347
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 20 additions & 14 deletions src/gui/folderwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -160,4 +147,23 @@ void FolderWatcher::changeDetected(const QSet<QString> &paths)
}
}

QSet<QString> 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
4 changes: 4 additions & 0 deletions src/gui/folderwatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class FolderWatcher : public QObject
/// For testing linux behavior only
int testLinuxWatchCount() const;

// pop the accumulated changes
QSet<QString> popChangeSet();


signals:
/** Emitted when one of the watched directories or one
* of the contained files is changed. */
Expand Down

0 comments on commit ac13bd5

Please sign in to comment.