diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 44aa230c2..0e1031dd5 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -258,6 +258,11 @@ void AccountSettings::doExpand() void AccountSettings::slotEncryptionFlagSuccess(const QByteArray& fileId) { + if (auto info = _model->infoForFileId(fileId)) { + accountsState()->account()->e2e()->setFolderEncryptedStatus(info->_path, true); + } else { + qCInfo(lcAccountSettings()) << "Could not get information from the current folder."; + } auto lockJob = new LockEncryptFolderApiJob(accountsState()->account(), fileId); connect(lockJob, &LockEncryptFolderApiJob::success, this, &AccountSettings::slotLockFolderSuccess); @@ -332,7 +337,16 @@ void AccountSettings::slotMarkSubfolderDecrypted(const QByteArray& fileId) { auto job = new OCC::DeleteApiJob(accountsState()->account(), "ocs/v2.php/apps/end_to_end_encryption/api/v1/encrypted/" + QString(fileId)); - connect(job, &OCC::DeleteApiJob::result, [](int httpResponse) { + connect(job, &OCC::DeleteApiJob::result, [this, &fileId](int httpResponse) { + if (httpResponse == 200) { + if (auto info = _model->infoForFileId(fileId)) { + accountsState()->account()->e2e()->setFolderEncryptedStatus(info->_path, false); + } else { + qCInfo(lcAccountSettings()) << "Could not get information for the current path."; + } + } else { + qCInfo(lcAccountSettings()) << "Response different than 200, cannot set folder to false."; + } qCInfo(lcAccountSettings) << "Decrypt Http Response" << httpResponse; }); job->start(); diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index cf358eb4c..d08c4a75b 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -676,6 +676,11 @@ void ClientSideEncryption::publicKeyFetched(Job *incoming) { job->start(); } +void ClientSideEncryption::setFolderEncryptedStatus(const QString& folder, bool status) +{ + _folder2encryptedStatus[folder] = status; +} + void ClientSideEncryption::privateKeyFetched(Job *incoming) { ReadPasswordJob *readJob = static_cast(incoming); diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h index de15f3799..870c07d53 100644 --- a/src/libsync/clientsideencryption.h +++ b/src/libsync/clientsideencryption.h @@ -47,6 +47,7 @@ public: // to be used together with FolderStatusModel::FolderInfo::_path. bool isFolderEncrypted(const QString& path); + void setFolderEncryptedStatus(const QString& path, bool status); private slots: void folderEncryptedStatusFetched(const QMap &values); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 805861a3b..4dddd659d 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -962,6 +962,7 @@ bool DeleteApiJob::finished() const auto replyData = QString::fromUtf8(reply()->readAll()); qCInfo(lcJsonApiJob()) << "TMX Delete Job" << replyData; + emit result(statusCode); return true; }