1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2025-05-08 02:34:09 +02:00

Ensure GETFileJob notices finishing

It could happen that readyRead was emitted for incoming data while the
download was not yet finished. Then the network job could finish with
no more data arriving - so readyRead wasn't emitted again.

To fix this, the finished signal also gets connected to the readyRead
slot.
This commit is contained in:
Christian Kamm 2018-06-13 14:20:21 +02:00 committed by Camila San
parent cb69944b5c
commit cba0627a9c
No known key found for this signature in database
GPG Key ID: 7A4A6121E88E2AD4
3 changed files with 12 additions and 1 deletions

View File

@ -149,6 +149,7 @@ void GETFileJob::newReplyHook(QNetworkReply *reply)
connect(reply, &QNetworkReply::metaDataChanged, this, &GETFileJob::slotMetaDataChanged);
connect(reply, &QIODevice::readyRead, this, &GETFileJob::slotReadyRead);
connect(reply, &QNetworkReply::finished, this, &GETFileJob::slotReadyRead);
connect(reply, &QNetworkReply::downloadProgress, this, &GETFileJob::downloadProgress);
}

View File

@ -728,9 +728,18 @@ public:
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, _httpErrorCode);
setError(InternalServerError, "Internal Server Fake Error");
emit metaDataChanged();
emit readyRead();
// finishing can come strictly after readyRead was called
QTimer::singleShot(5, this, &FakeErrorReply::slotSetFinished);
}
public slots:
void slotSetFinished() {
setFinished(true);
emit finished();
}
public:
void abort() override { }
qint64 readData(char *, qint64) override { return 0; }

View File

@ -255,7 +255,8 @@ private slots:
} else if(item->_file == "Y/Z/d3") {
QVERIFY(item->_status != SyncFileItem::Success);
}
QVERIFY(item->_file != "Y/Z/d9"); // we should have aborted the sync before d9 starts
// We do not know about the other files - maybe the sync was aborted,
// maybe they finished before the error caused the abort.
}
}