From 52dcfcb1663cd5595560c6c203fcf8fa2786a5de Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 9 Oct 2018 15:12:02 +0200 Subject: [PATCH] New Propagation algorithm: Fetch, and emit, the root etag Remove the feature to concatenate etags as servers that don't have a root etag are no longer suported --- src/libsync/account.cpp | 5 ----- src/libsync/account.h | 4 ---- src/libsync/discovery.cpp | 1 + src/libsync/discovery.h | 2 ++ src/libsync/discoveryphase.cpp | 3 --- src/libsync/discoveryphase.h | 2 -- src/libsync/networkjobs.cpp | 11 +---------- src/libsync/syncengine.cpp | 11 +---------- 8 files changed, 5 insertions(+), 34 deletions(-) diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index ee4ee1ffa..3f3c592b4 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -513,11 +513,6 @@ void Account::setServerVersion(const QString &version) emit serverVersionChanged(this, oldServerVersion, version); } -bool Account::rootEtagChangesNotOnlySubFolderEtags() -{ - return (serverVersionInt() >= makeServerVersion(8, 1, 0)); -} - void Account::setNonShib(bool nonShib) { if (nonShib) { diff --git a/src/libsync/account.h b/src/libsync/account.h index 92008ff08..7036072a5 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -219,10 +219,6 @@ public: */ bool serverVersionUnsupported() const; - // Fixed from 8.1 https://github.com/owncloud/client/issues/3730 - /** Detects a specific bug in older server versions */ - bool rootEtagChangesNotOnlySubFolderEtags(); - /** True when the server connection is using HTTP2 */ bool isHttp2Supported() { return _http2Supported; } void setHttp2Supported(bool value) { _http2Supported = value; } diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index a5433b9b4..0f1e29808 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -37,6 +37,7 @@ void ProcessDirectoryJob::start() if (_queryServer == NormalQuery) { serverJob = new DiscoverySingleDirectoryJob(_discoveryData->_account, _discoveryData->_remoteFolder + _currentFolder._server, this); + connect(serverJob, &DiscoverySingleDirectoryJob::etag, this, &ProcessDirectoryJob::etag); connect(serverJob, &DiscoverySingleDirectoryJob::finished, this, [this, serverJob](const auto &results) { if (results) { _serverEntries = *results; diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h index 4677b1ab4..783280f77 100644 --- a/src/libsync/discovery.h +++ b/src/libsync/discovery.h @@ -107,5 +107,7 @@ private: signals: void finished(); + // The root etag of this directory was fetched + void etag(const QString &); }; } diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index f645b63a8..65491f600 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -311,8 +311,6 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file, con //This works in concerto with the RequestEtagJob and the Folder object to check if the remote folder changed. if (map.contains("getetag")) { - _etagConcatenation += map.value("getetag"); - if (_firstEtag.isEmpty()) { _firstEtag = map.value("getetag"); // for directory itself } @@ -333,7 +331,6 @@ void DiscoverySingleDirectoryJob::lsJobFinishedWithoutErrorSlot() return; } emit etag(_firstEtag); - emit etagConcatenation(_etagConcatenation); emit finished(_results); deleteLater(); } diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 8a6c00102..c447a595b 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -92,7 +92,6 @@ public: // This is not actually a network job, it is just a job signals: void firstDirectoryPermissions(RemotePermissions); - void etagConcatenation(const QString &); void etag(const QString &); void finished(const Result> &result); private slots: @@ -103,7 +102,6 @@ private slots: private: QVector _results; QString _subPath; - QString _etagConcatenation; QString _firstEtag; AccountPtr _account; // The first result is for the directory itself and need to be ignored. diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 2e2eacd47..ccedf4d28 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -62,16 +62,7 @@ RequestEtagJob::RequestEtagJob(AccountPtr account, const QString &path, QObject void RequestEtagJob::start() { QNetworkRequest req; - if (_account && _account->rootEtagChangesNotOnlySubFolderEtags()) { - // Fixed from 8.1 https://github.com/owncloud/client/issues/3730 - req.setRawHeader("Depth", "0"); - } else { - // Let's always request all entries inside a directory. There are/were bugs in the server - // where a root or root-folder ETag is not updated when its contents change. We work around - // this by concatenating the ETags of the root and its contents. - req.setRawHeader("Depth", "1"); - // See https://github.com/owncloud/core/issues/5255 and others - } + req.setRawHeader("Depth", "0"); QByteArray xml("\n" "\n" diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index c6d4aa2f2..718f8107c 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -618,16 +618,7 @@ void SyncEngine::slotStartDiscovery() auto discoveryJob = new ProcessDirectoryJob(SyncFileItemPtr(), ProcessDirectoryJob::NormalQuery, ProcessDirectoryJob::NormalQuery, _discoveryPhase.data(), _discoveryPhase.data()); _discoveryPhase->startJob(discoveryJob); - - /* - * FIXME - if (account()->rootEtagChangesNotOnlySubFolderEtags()) { - connect(_discoveryMainThread.data(), &DiscoveryMainThread::etag, this, &SyncEngine::slotRootEtagReceived); - } else { - connect(_discoveryMainThread.data(), &DiscoveryMainThread::etagConcatenation, this, &SyncEngine::slotRootEtagReceived); - } - - */ + connect(discoveryJob, &ProcessDirectoryJob::etag, this, &SyncEngine::slotRootEtagReceived); } void SyncEngine::slotFolderDiscovered(bool local, const QString &folder) -- 2.30.2