Skip to content

Commit

Permalink
Merge pull request #634 from nextcloud/upstream/issue/6581
Browse files Browse the repository at this point in the history
Ensure GETFileJob notices finishing #6581
  • Loading branch information
rullzer authored Oct 23, 2018
2 parents 4e86612 + c37186c commit 305952e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/libsync/propagatedownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 9 additions & 0 deletions test/syncenginetestutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,18 @@ class FakeErrorReply : public QNetworkReply
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; }

Expand Down
3 changes: 2 additions & 1 deletion test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}

Expand Down

0 comments on commit 305952e

Please sign in to comment.