Start managing a list of GetFolderEncryptStatusJob
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 20 Oct 2020 14:27:20 +0000 (16:27 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 21 Oct 2020 08:00:58 +0000 (10:00 +0200)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/clientsideencryption.cpp
src/libsync/clientsideencryption.h

index 7d6c0ef4503dd7df84fa21015b9681c9e790377f..f59051830338212155da0536f52c7659ae0aecca 100644 (file)
@@ -1241,7 +1241,8 @@ void ClientSideEncryption::getPublicKeyFromServer()
     job->start();
 }
 
-void ClientSideEncryption::fetchFolderEncryptedStatus() {
+void ClientSideEncryption::fetchFolderEncryptedStatus()
+{
     _refreshingEncryptionStatus = true;
     auto getEncryptedStatus = new GetFolderEncryptStatusJob(_account, QString());
     connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusReceived,
@@ -1249,10 +1250,17 @@ void ClientSideEncryption::fetchFolderEncryptedStatus() {
     connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusError,
                     this, &ClientSideEncryption::folderEncryptedStatusError);
     getEncryptedStatus->start();
+
+    _folderStatusJobs.append(getEncryptedStatus);
 }
 
 void ClientSideEncryption::folderEncryptedStatusFetched(const QHash<QString, bool>& result)
 {
+    auto job = static_cast<GetFolderEncryptStatusJob *>(sender());
+    Q_ASSERT(job);
+
+    _folderStatusJobs.removeAll(job);
+
     _refreshingEncryptionStatus = false;
     _folder2encryptedStatus = result;
     qCDebug(lcCse) << "Retrieved correctly the encrypted status of the folders." << result;
@@ -1261,6 +1269,11 @@ void ClientSideEncryption::folderEncryptedStatusFetched(const QHash<QString, boo
 
 void ClientSideEncryption::folderEncryptedStatusError(int error)
 {
+    auto job = static_cast<GetFolderEncryptStatusJob *>(sender());
+    Q_ASSERT(job);
+
+    _folderStatusJobs.removeAll(job);
+
     _refreshingEncryptionStatus = false;
     qCDebug(lcCse) << "Failed to retrieve the status of the folders." << error;
     emit folderEncryptedStatusFetchDone({});
index 13ec980432008c2aac250ad113d89e032d80864e..eea0e4a97b952bee26f06387774209147b077c2d 100644 (file)
@@ -23,6 +23,8 @@ class ReadPasswordJob;
 
 namespace OCC {
 
+class GetFolderEncryptStatusJob;
+
 QString baseUrl();
 
 namespace EncryptionHelper {
@@ -125,6 +127,7 @@ private:
     //TODO: Save this on disk.
     QHash<QByteArray, QByteArray> _folder2token;
     QHash<QString, bool> _folder2encryptedStatus;
+    QVector<GetFolderEncryptStatusJob*> _folderStatusJobs;
 
 public:
     //QSslKey _privateKey;