Don't use depth infinity anymore to get the folders e2ee status
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 20 Oct 2020 15:05:57 +0000 (17:05 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 21 Oct 2020 08:00:59 +0000 (10:00 +0200)
This way we avoid the expensive SQL query on the server at the price of
more round-trips since we're doing the recursive traversal by hand now.

Also it turns out this depth was used for all the other propfind calls
during sync when we want fresher information regarding a folder. This
was very inefficient in all cases and won't happen anymore.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/clientsideencryption.cpp
src/libsync/clientsideencryptionjobs.cpp

index 340416a89bc67064b686c41cd5915a205da100f3..134a834256ccdb17d7ffa59ebcb63967f0412569 100644 (file)
@@ -1274,8 +1274,17 @@ void ClientSideEncryption::folderEncryptedStatusFetched(const QHash<QString, boo
         _folder2encryptedStatus.insert((*it).first, (*it).second);
     }
 
-    _refreshingEncryptionStatus = false;
-    emit folderEncryptedStatusFetchDone(_folder2encryptedStatus);
+    for (const auto &folder : result.keys()) {
+        if (folder == job->folder()) {
+            continue;
+        }
+        scheduleFolderEncryptedStatusJob(folder);
+    }
+
+    if (_folderStatusJobs.isEmpty()) {
+        _refreshingEncryptionStatus = false;
+        emit folderEncryptedStatusFetchDone(_folder2encryptedStatus);
+    }
 }
 
 void ClientSideEncryption::folderEncryptedStatusError(int error)
@@ -1287,8 +1296,10 @@ void ClientSideEncryption::folderEncryptedStatusError(int error)
 
     _folderStatusJobs.removeAll(job);
 
-    _refreshingEncryptionStatus = false;
-    emit folderEncryptedStatusFetchDone(_folder2encryptedStatus);
+    if (_folderStatusJobs.isEmpty()) {
+        _refreshingEncryptionStatus = false;
+        emit folderEncryptedStatusFetchDone(_folder2encryptedStatus);
+    }
 }
 
 FolderMetadata::FolderMetadata(AccountPtr account, const QByteArray& metadata, int statusCode) : _account(account)
index f772fc8797faa005d7a47fa29ad67c06fcd4ec92..505bd99f5af8e741b1fd3873345865a0fffcd61e 100644 (file)
@@ -40,7 +40,7 @@ void GetFolderEncryptStatusJob::start()
        req.setPriority(QNetworkRequest::HighPriority);
        req.setRawHeader("OCS-APIREQUEST", "true");
     req.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/xml"));
-    req.setRawHeader("Depth", "infinity");
+    req.setRawHeader("Depth", "1");
 
        QByteArray xml = R"(<d:propfind xmlns:d="DAV:"> <d:prop xmlns:nc="http://nextcloud.org/ns"> <nc:is-encrypted/> </d:prop> </d:propfind>)";
        auto *buf = new QBuffer(this);