Have the folder token inside the EncryptFolderJob
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 7 Dec 2020 16:38:18 +0000 (17:38 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:22 +0000 (10:59 +0100)
No need to look for a token on the outside we can just work properly by
keeping all the state encapsulated in the job.

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

index bbf8619ffc323c9e2a3d31859b0554a62607f478..2fa091ae4f2455bed7a69c2c8430f965a134ea5f 100644 (file)
@@ -63,7 +63,7 @@ void EncryptFolderJob::slotEncryptionFlagError(const QByteArray &fileId, int htt
 
 void EncryptFolderJob::slotLockForEncryptionSuccess(const QByteArray &fileId, const QByteArray &token)
 {
-    _account->e2e()->setTokenForFolder(fileId, token);
+    _folderToken = token;
 
     FolderMetadata emptyMetadata(_account);
     auto encryptedMetadata = emptyMetadata.encryptedMetadata();
@@ -85,8 +85,7 @@ void EncryptFolderJob::slotLockForEncryptionSuccess(const QByteArray &fileId, co
 
 void EncryptFolderJob::slotUploadMetadataSuccess(const QByteArray &folderId)
 {
-    const auto token = _account->e2e()->tokenForFolder(folderId);
-    auto unlockJob = new UnlockEncryptFolderApiJob(_account, folderId, token, this);
+    auto unlockJob = new UnlockEncryptFolderApiJob(_account, folderId, _folderToken, this);
     connect(unlockJob, &UnlockEncryptFolderApiJob::success,
                     this, &EncryptFolderJob::slotUnlockFolderSuccess);
     connect(unlockJob, &UnlockEncryptFolderApiJob::error,
@@ -98,8 +97,7 @@ void EncryptFolderJob::slotUpdateMetadataError(const QByteArray &folderId, int h
 {
     Q_UNUSED(httpReturnCode);
 
-    const auto token = _account->e2e()->tokenForFolder(folderId);
-    auto unlockJob = new UnlockEncryptFolderApiJob(_account, folderId, token, this);
+    auto unlockJob = new UnlockEncryptFolderApiJob(_account, folderId, _folderToken, this);
     connect(unlockJob, &UnlockEncryptFolderApiJob::success,
                     this, &EncryptFolderJob::slotUnlockFolderSuccess);
     connect(unlockJob, &UnlockEncryptFolderApiJob::error,
index 142e25345477510215cb28779a3616a2dbea58d0..ff071f8f22e872f9837025353ae9e6a0d6849de0 100644 (file)
@@ -51,6 +51,7 @@ private:
     AccountPtr _account;
     QString _path;
     QByteArray _fileId;
+    QByteArray _folderToken;
     QString _errorString;
 };
 }