diff options
author | Christian Kamm <mail@ckamm.de> | 2019-04-12 11:59:24 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2019-04-12 13:18:02 +0300 |
commit | 6a7b138aa64e05a5c416969e5369d3434700611e (patch) | |
tree | 4a36bb424c2ad482aa6a4c77d9673456b1709d07 | |
parent | 440c06c54a9012a115a7b39f1096e90edebb4b5a (diff) |
Discovery: Query data-fingerprint on root item
Previously the property wasn't queried, meaning the fingerprint logic
couldn't get triggered.
-rw-r--r-- | src/libsync/discovery.cpp | 2 | ||||
-rw-r--r-- | test/testallfilesdeleted.cpp | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 7dce97b4c..17815b851 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1320,6 +1320,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 e0dbbdd44..03a91e244 100644 --- a/test/testallfilesdeleted.cpp +++ b/test/testallfilesdeleted.cpp @@ -204,7 +204,24 @@ private slots: //Server support finger print, but none is set. fakeFolder.remoteModifier().extraDavProperties = "<oc:data-fingerprint></oc:data-fingerprint>"; } + + 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'); @@ -230,6 +247,7 @@ private slots: fakeFolder.remoteModifier().extraDavProperties = "<oc:data-fingerprint>new_finger_print</oc:data-fingerprint>"; 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'); |