Don't use depth infinity anymore to get the folders e2ee status

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>
This commit is contained in:
Kevin Ottens 2020-10-20 17:05:57 +02:00
parent b5fdbefb0e
commit 10cb4170c7
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 16 additions and 5 deletions

View 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)

View 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);