Have the folder token inside the EncryptFolderJob

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>
This commit is contained in:
Kevin Ottens 2020-12-07 17:38:18 +01:00
parent af00ef1cca
commit ee8e0fa332
No known key found for this signature in database
GPG Key ID: 074BBBCB8DECC9E2
2 changed files with 4 additions and 5 deletions

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

View File

@ -51,6 +51,7 @@ private:
AccountPtr _account;
QString _path;
QByteArray _fileId;
QByteArray _folderToken;
QString _errorString;
};
}