Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsync/propagatedownload.cpp9
-rw-r--r--test/syncenginetestutils.h5
2 files changed, 11 insertions, 3 deletions
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 56f635c1c..ae9ddf7a8 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -165,6 +165,9 @@ void GETFileJob::slotMetaDataChanged()
// 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) {
+ // Disable the buffer limit, as we don't limit the bandwidth for error messages.
+ // (We are only going to do a readAll() at the end.)
+ reply()->setReadBufferSize(0);
_device->close();
return;
}
@@ -268,7 +271,7 @@ void GETFileJob::slotReadyRead()
int bufferSize = qMin(1024 * 8ll, reply()->bytesAvailable());
QByteArray buffer(bufferSize, Qt::Uninitialized);
- while (reply()->bytesAvailable() > 0) {
+ while (reply()->bytesAvailable() > 0 && _saveBodyToFile) {
if (_bandwidthChoked) {
qCWarning(lcGetJob) << "Download choked";
break;
@@ -292,7 +295,7 @@ void GETFileJob::slotReadyRead()
return;
}
- if (_device->isOpen() && _saveBodyToFile) {
+ if (_device->isOpen()) {
qint64 w = _device->write(buffer.constData(), r);
if (w != r) {
_errorString = _device->errorString();
@@ -304,7 +307,7 @@ void GETFileJob::slotReadyRead()
}
}
- if (reply()->isFinished() && reply()->bytesAvailable() == 0) {
+ if (reply()->isFinished() && (reply()->bytesAvailable() == 0 || !_saveBodyToFile)) {
qCDebug(lcGetJob) << "Actually finished!";
if (_bandwidthManager) {
_bandwidthManager->unregisterDownloadJob(this);
diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h
index 1a78add5b..3957479d6 100644
--- a/test/syncenginetestutils.h
+++ b/test/syncenginetestutils.h
@@ -728,6 +728,8 @@ public:
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, _httpErrorCode);
setError(InternalServerError, "Internal Server Fake Error");
emit metaDataChanged();
+ emit readyRead();
+ setFinished(true);
emit finished();
}
@@ -738,6 +740,9 @@ public:
_body = _body.mid(max);
return max;
}
+ qint64 bytesAvailable() const override {
+ return _body.size();
+ }
int _httpErrorCode;
QByteArray _body;