mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
[CSE] Bypass Qt DELETE Bug
It appears that Qt implementation of the DELETE http request does not send bodyData, and we need that for Nextcloud. Currently I changed the http request on the server side to accept a POST instead of a DELETE, so I can actually develop. Also, I already poked the Qt developers that did this code.
This commit is contained in:
parent
6ad6852045
commit
be9cd358d4
@ -272,9 +272,8 @@ void AccountSettings::slotEncryptionFlagError(const QByteArray& fileId, int http
|
||||
|
||||
void AccountSettings::slotLockFolderSuccess(const QByteArray& fileId, const QByteArray &token)
|
||||
{
|
||||
qCInfo(lcAccountSettings()) << "Locked Successfully";
|
||||
FolderMetadata emptyMetadata(accountsState()->account());
|
||||
|
||||
// FolderMetadata emptyMetadata(accountsState()->account());
|
||||
qCInfo(lcAccountSettings()) << "Folder Locked Successfully" << fileId << token;
|
||||
auto unlockJob = new UnlockEncryptFolderApiJob(accountsState()->account(), fileId, token);
|
||||
connect(unlockJob, &UnlockEncryptFolderApiJob::success,
|
||||
this, &AccountSettings::slotUnlockFolderSuccess);
|
||||
|
||||
@ -1026,7 +1026,7 @@ UnlockEncryptFolderApiJob::UnlockEncryptFolderApiJob(const AccountPtr& account,
|
||||
const QByteArray& fileId,
|
||||
const QByteArray& token,
|
||||
QObject* parent)
|
||||
: AbstractNetworkJob(account, baseUrl() + QStringLiteral("lock/") + fileId, parent), _fileId(fileId), _token(token)
|
||||
: AbstractNetworkJob(account, baseUrl() + QStringLiteral("unlock/") + fileId, parent), _fileId(fileId), _token(token)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1035,17 +1035,20 @@ void UnlockEncryptFolderApiJob::start()
|
||||
QNetworkRequest req;
|
||||
req.setRawHeader("OCS-APIREQUEST", "true");
|
||||
QUrl url = Utility::concatUrlPath(account()->url(), path());
|
||||
QList<QPair<QString, QString>> params = {
|
||||
qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json")),
|
||||
};
|
||||
url.setQueryItems(params);
|
||||
|
||||
// TODO: This should be a data parameter.
|
||||
// qMakePair(QString::fromLatin1("token"), _token)
|
||||
QByteArray bufferData("token=" + _token);
|
||||
_tokenBuf = new QBuffer();
|
||||
_tokenBuf->setData(bufferData);
|
||||
|
||||
qCInfo(lcCseJob()) << "================";
|
||||
qCInfo(lcCseJob()) << "unlocking the folder with id" << _fileId << "with token" << _token;
|
||||
qCInfo(lcCseJob()) << url;
|
||||
qCInfo(lcCseJob()) << bufferData;
|
||||
qCInfo(lcCseJob()) << "===================";
|
||||
sendRequest("POST", url, req, _tokenBuf);
|
||||
|
||||
qCInfo(lcCseJob()) << "unlocking the folder with id" << _fileId << "as encrypted";
|
||||
sendRequest("DELETE", url, req);
|
||||
AbstractNetworkJob::start();
|
||||
qCInfo(lcCseJob()) << "Starting the request to unlock.";
|
||||
}
|
||||
|
||||
bool UnlockEncryptFolderApiJob::finished()
|
||||
@ -1053,6 +1056,7 @@ bool UnlockEncryptFolderApiJob::finished()
|
||||
int retCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (retCode != 200) {
|
||||
qCInfo(lcCseJob()) << "error unlocking file" << path() << errorString() << retCode;
|
||||
qCInfo(lcCseJob()) << "Full Error Log" << reply()->readAll();
|
||||
emit error(_fileId, retCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -243,6 +243,7 @@ signals:
|
||||
private:
|
||||
QByteArray _fileId;
|
||||
QByteArray _token;
|
||||
QBuffer *_tokenBuf;
|
||||
};
|
||||
|
||||
class OWNCLOUDSYNC_EXPORT StoreMetaDataApiJob : public AbstractNetworkJob
|
||||
|
||||
Loading…
Reference in New Issue
Block a user