Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include recent change events in local discover #11347

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -963,6 +963,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
Loading