mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 19:58:56 +03:00
Download: Don't store message body if status != 2xx #2280
This commit is contained in:
parent
48d3c75745
commit
705cd571a5
1 changed files with 18 additions and 10 deletions
|
@ -482,9 +482,15 @@ void GETFileJob::start() {
|
|||
|
||||
void GETFileJob::slotMetaDataChanged()
|
||||
{
|
||||
if (reply()->error() != QNetworkReply::NoError
|
||||
|| reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() / 100 != 2) {
|
||||
// We will handle the error when the job is finished.
|
||||
int httpStatus = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
|
||||
// If the status code isn't 2xx, don't write the reply body to the file.
|
||||
// For any error: handle it when the job is finished, not here.
|
||||
if (httpStatus / 100 != 2) {
|
||||
_device->close();
|
||||
return;
|
||||
}
|
||||
if (reply()->error() != QNetworkReply::NoError) {
|
||||
return;
|
||||
}
|
||||
_etag = get_etag_from_reply(reply());
|
||||
|
@ -554,6 +560,7 @@ void GETFileJob::slotReadyRead()
|
|||
return;
|
||||
}
|
||||
|
||||
if (_device->isOpen()) {
|
||||
qint64 w = _device->write(buffer.constData(), r);
|
||||
if (w != r) {
|
||||
_errorString = _device->errorString();
|
||||
|
@ -563,6 +570,7 @@ void GETFileJob::slotReadyRead()
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GETFileJob::slotTimeout()
|
||||
|
|
Loading…
Reference in a new issue