From: Christian Kamm Date: Fri, 12 Apr 2019 08:59:24 +0000 (+0200) Subject: Discovery: Query data-fingerprint on root item X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~251 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fbe2dbf4ab8296306df1062e721778aa1173c041;p=nextcloud-desktop.git Discovery: Query data-fingerprint on root item Previously the property wasn't queried, meaning the fingerprint logic couldn't get triggered. --- diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 6a3d04f36..60226d404 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1328,6 +1328,8 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery() { auto serverJob = new DiscoverySingleDirectoryJob(_discoveryData->_account, _discoveryData->_remoteFolder + _currentFolder._server, this); + if (!_dirItem) + serverJob->setIsRootPath(); // query the fingerprint on the root connect(serverJob, &DiscoverySingleDirectoryJob::etag, this, &ProcessDirectoryJob::etag); _discoveryData->_currentlyActiveJobs++; _pendingAsyncJobs++; diff --git a/test/testallfilesdeleted.cpp b/test/testallfilesdeleted.cpp index f85debef3..894503f10 100644 --- a/test/testallfilesdeleted.cpp +++ b/test/testallfilesdeleted.cpp @@ -207,7 +207,24 @@ private slots: //Server support finger print, but none is set. fakeFolder.remoteModifier().extraDavProperties = ""; } + + int fingerprintRequests = 0; + fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation, const QNetworkRequest &request, QIODevice *stream) -> QNetworkReply * { + auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute); + if (verb == "PROPFIND") { + auto data = stream->readAll(); + if (data.contains("data-fingerprint")) { + if (request.url().path().endsWith("webdav/")) + ++fingerprintRequests; + else + fingerprintRequests = -10000; // fingerprint queried on incorrect path + } + } + return nullptr; + }); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fingerprintRequests, 1); // First sync, we did not change the finger print, so the file should be downloaded as normal QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentRemoteState().find("C/c1")->contentChar, 'N'); @@ -233,6 +250,7 @@ private slots: fakeFolder.remoteModifier().extraDavProperties = "new_finger_print"; QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fingerprintRequests, 2); auto currentState = fakeFolder.currentLocalState(); // Altough the local file is kept as a conflict, the server file is downloaded QCOMPARE(currentState.find("A/a1")->contentChar, 'O');